Build microservices in Node.js with micro

Max Stoiber
InstructorMax Stoiber
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 5 years ago

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.

[00:01] First, we npm-install the micro module with the -g global flag. This will give us access to the micro command, which we'll use later on to start our micro service. Then we create an index.js file, which we will write our first micro service into.

[00:16] In this file, we require the send function from micro. This is the main function we'll use when writing your micro services. It allows you to send responses back to the client. To write our micro service, all we have to do is export the function, which gets two arguments, the request that comes in and the response object, which we can send back to the client.

[00:40] Let's do that. We use the send function to send the response object with an http status code of 200, which means a successful request, and a body. In our case, we'll say, "Hello, world." We'll save this and start our first micro service by typing micro index.js.

[00:59] This starts our micro service. As you can see, we can access it at 0000and then port 3000. If you open this in your browser, you will see that our micro service responds with our "Hello, World" message.

Marko
Marko
~ 7 years ago

How can we debug such apps?

alpa
alpa
~ 5 years ago

Nothing found for MicroFrontends (micro services on front-end) :(

Markdown supported.
Become a member to join the discussionEnroll Today