您的位置:首页 > Web前端 > Node.js

[Node.js] Build microservices in Node.js with micro

2017-01-26 21:41 555 查看
micro is a small module that makes it easy to write high performance and asynchronous microservices in Node.js. This video will introduce you to micro by building a tiny service that responds to all requests.

const {send} = require('micro');
const sleep = require('then-sleep');

// Just send method
module.exports = (req, res) => {
send(res, 200, 'Hello World!')
}

// Just use return
module.exports = (req, res) => {
return 'Hello World return';
}

// Easy to use async await
module.exports = async function(req, res){
await sleep(5000)
send(res, 200, 'Ready!')
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: