Express - Elastic Search -Monitoring
The tsconfig.json should look something similar to this:Create src foldernpm init -y
The command npm init -y quickly creates a new package.json file for a Node.js project with
default values, skipping the interactive setup process.npm install -g typescript
The command npm install -g typescript installs TypeScript globally
on your computer, making the TypeScript compiler (tsc) available from any
command line interface.npm install typescript --save-dev
The command npm install typescript --save-dev installs TypeScript
as a development dependency in your Node.js project,
saving it in your package.json under devDependencies.npx tsc --init
Create index.ts inside src folder
Change package.jsonnpm install --save-dev ts-node nodemon
from the cli.
npm install express
Next:
npm install --save-dev @types/express
Next:
npm install express log4js
Next:
npm install --save-dev @types/express @types/log4js
Create folder helper - src/helper
Create logger.ts inside helper
npm install dotenv
Create file .env in the main directory
Write in your src/index.ts -
console.log('Hello TypeScript!')
and run the project:
npm run dev
And this is what you should see in your log file:
And if we make a request (I am using thunder client addon to visual studio, but postman can be used too):Next Step
Next step is to build the controller. Create a new folder inside src called controller and inside create a new file called AppController.ts
Next step is to create a new folder inside the src called router. Inside router create a new file called appRouter.ts
Next step is to update src/index.ts
and test to see the results. The app should be running for that goal ('not to forget in cli npm run dev')
On that pic we can see in thunder client the results from testing the requests
And we can see the results in the log file
This is the end of part 1, click here to continue to the part 2
ELK Monitoring - https://github.com/cholakovit/elk-monitoring-tutorial