[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!') }
相关文章推荐
- Displaying an image with EJS in node.js/express
- Build nodejs express framework in MACOS
- Build File Server With NodeJS
- Node.js Request Module…sending json in body for api request with put
- 微服务免费书籍:Evolve the Monolith to Microservices with Java and Node
- Javascript Module pattern template. Shows a class with a constructor and public/private methods/properties. Also shows compatibility with CommonJS(eg Node.JS) and AMD (eg requireJS) as well as in a br
- Build Node.Js web server in Docker containers: nodejs+pm2+mongodb+redis
- How to disable 'withcredentials' in HTTP header with node.js and Request package?
- How To Work With JSON In Node.js / JavaScript
- [Docker] Build a Simple Node.js Web Server with Docker
- Testing in Node.js with Mocha
- Using HTTP Proxy in Node.js with request package
- Build node.js with clang.
- jsdom + jQuery in 5 lines with node.js
- [Test] Easy automated testing in NodeJS with TestCafe
- js中用于对象的语句——with和for...in语句学习专题
- A Simple MVC Setup In Node.JS
- Callback in NodeJS
- Node.js: Building for Scalability with Server-Side JavaScript
- Multi-Core HTTP Server with NodeJS