O'Reilly logo

Hands-On Microservices with Node.js by Diogo Resende

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Micro

Let's look at another interesting tool. This module is called micro and was created by ZEIT, a team of some of the most influential Node.js developers. It is meant to be a minimalistic framework to create slim and fast microservices.

Let's repeat our first example. Create a folder and run the following command:

npm init -ynpm install --save micro

Now, create a file called app.js and write the following code inside it:

module.exports = (req, res) => {    res.end("Hello World");};

Change your scripts property in package.json to this:

"scripts": {    "start": "micro"},

Now, just run this:

npm start

You'll see something like this, which indicates that a micro is running on its default port, 3000:

micro: Accepting connections on port 3000

You ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required