Code Monkey home page Code Monkey logo

vig's Introduction

vig NPM version Build Status Dependency Status Coverage percentage

关于vig

是一个专注于Web业务逻辑的组件化框架,主要关心:

  1. 精减Web业务处理的代码
  2. 简化常规Web业务的处理
  3. 加速项目的开发
  4. 是一个简化Web业务处理的Web框架
  5. 将Web的业务逻辑标准化,可重用化是vig的主要目标

目标是:

  1. 模块化(Modular)
  2. 可插件化(Pluggable)
  3. 可重入化(Reenterable)
  4. 可集成化(Integratable)

功能列表

  1. 组件化,所的功能都是组件级的
  2. 简化的路由机制
  3. 简洁,而强大的数据输入校检
  4. 方便的权限验证功能
  5. 框架内的事件机制
  6. 实用的VIG API规范支持
  7. 简单的文件上传机制
  8. 简单的模型定义方式(基于waterline)
  9. 统一的错误处理机制(基于Errorable)
  10. 组件配置支持与全局配置支持
  11. 模板支持

快速上手

1、创建一个test.js文件

vi test.js

2、添加如下代码

var app = require('express')();
var vig = require('vig');
vig.init(app);
vig.addHandler(app, {
  prefix: '/demo',
  urls: ['/', '/hello'],
  routers: {
    get: function (req, res) {
      res.send('Hello world!');
    }
  }
});

app.listen(10000, function () {
  console.log('server running on http://localhost:10000');
});

3、执行

npm install --save vig
npm install --save express

4、测试

npm test

教程

第一章 最简服务器创建  

第二章 URL路由(别名与前缀)机制  

第三章 vig的http方法机制详解  

第四章 输入数据的校验与提取  

第五章 输入数据的校验与提取(二)  

第六章 输入数据的校验与提取(三)  

第七章 基于waterline操作数据库与模型  

第八章 在vig中进行错误处理  

第九章 在vig中进行文件处理(未完成)    

第十章 应用权限机制(未完成)    

第十一章 错误处理机制(未完成)    

关于async/await支持的几点说明

vig对async/await的支持依赖于用户的开发环境本身,与vig框架无关。
但是开发者需要注意的是:

  1. async/await无法实现对事件的支持,所以回调函数与async/await是不同的。
  2. 回调函数不会消失,async/await也无法适用于所有的场景

所以在使用vig框架时需要注意事件与IO回调的区别。

下面再将事件与常规的IO调用的差别说明一下。

  1. IO的调用本身也是事件。
  2. IO调用本身也是可以不定期的,比如网络IO。
  3. 对于时间与任务明确的IO调用,推荐async/awati,比如数据库访问,文件访问等。
  4. 对于不明确的事件应该使用回调,比如有些网络IO,一些硬件的IO事件,如键盘事件,鼠标事件等。
  5. async/await无法取代回调函数

安装

$ npm install --save vig
$ yarn add vig

教程与文档

教程与文档;

项目地址

https://github.com/calidion/vig

License

Apache-2.0 © calidion

vig's People

Contributors

calidion avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.