Express - Elastic Search -Monitoring

Let's start our journey from the beginning by creating a new project! First, we need to create a folder called 'elk-express-ts-monitoring' and inside that folder, from the command prompt we need to execute:
npm 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
The tsconfig.json should look something similar to this:Create src folder
Create index.ts inside src folder
npm install --save-dev ts-node nodemon
Change package.json

from the cli.

npm install express


npm install --save-dev @types/express


npm install express log4js


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:

app logAnd if we make a request (I am using thunder client addon to visual studio, but postman can be used too):thunder client

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')

thunder client

On that pic we can see in thunder client the results from testing the requests

app log

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 -