ys-micro
v1.0.5
Published
micro base on net.socket
Downloads
3
Readme
ys-micro
YS 架构之微服务启动架构。
Install
npm install ys-micro --save
Usage
const Micro = require('ys-micro');
Server Side
const Service = require('ys-micro').Server;
const server = new Service();
server.use(async (ctx, next) => {
console.log('url', ctx.url);
console.log('data', ctx.data);
ctx.body = 'receive';
});
server.listen(6000, err => {
if (err) return console.error(err.message);
console.log('net server start on 127.0.0.1:6000');
});
Client Side
const Client = require('ys-micro').Client;
Client('127.0.0.1:6000/path/to/1222/reply', {
a: 1,
b: 2
}).then(console.log).catch(console.error);
License
It is MIT licensed.