Writing your first Hello World microservice
Let's start by writing our first microservice. Based on the previous topics, we will construct our first microservice with best practices and the widely used node_modules
. We will use:
CORS (https://www.npmjs.com/package/cors) | Adds CORS headers, so that cross applications can access it. |
Routing Controllers (https://www.npmjs.com/package/routing-controllers) | Beautiful decorators provided in this module, which help us to write our API's and routes easily. |
Winston (https://www.npmjs.com/package/winston) | Perfect logging module with many advanced features. |
So, open up a Terminal and create one Node project with a default package.json
. Follow these steps. The full source code for reference is available in the first-microservice
folder in the extracted source:
- First of all, we will download the preceding dependencies and basic express dependencies. Enter the following command lines:
npm install body-parser config cookie-parser cors debug express reflect-metadata...