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.
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.
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.
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.