0.5.2 • Published 6 years ago

@zcws/micro v0.5.2

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

micro组件

  • 本组件用于构建基于Node.js微服务,服务治理使用consul,RPC通讯使用HTTP,数据格式JSON-RPC 2.0。

如何安装

npm install @zcws/micro --save

如何使用

  • Server

    const { Server } = require('@zcws/micro');
    let server = new Server({
        port:'8500',
        host:'172.16.1.3'
    });
    
    //添加method
    server.method('add',function(args,done){
        let [a,b] = args;
        done(null,a+b);
    });
    
    //批量添加method
    server.methods({
        add(args,done){
            let [a,b] = args;
            done(null,a+b);
        }
    });
    
    //服务注册
    server.register({
        name:'wx',
        port:3000,
        address:'http://wx'
    });
    
    //express中间件
    app.use(server.middleware({ health:ture }));
  • Client

    const { Client } = require('@zcws/micro');
    let client = new Client({
        port:8500,
        host:'172.16.1.3',
        use:['auth','wx']
    });
    
    let result = await client.apply('wx','publish',{ openid... });
0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago