- Backend : Nodejs, Nestjs, TypeScript, Sequelize, Jest, SuperTest, Postgres
- API Design : The API is implemented Nestjs. It supports offset-limit based pagination for the list of candidates.
- Testing : All the Rest operations are tested using integration test cases using Jest and SuperTest.
- Linting & Formatting : The codebase is linted using ESLint and formatted using Prettier.
- Deployment : The Nestjs nodejs server can be dockerized and deployed in container orchestration platforms like Kubernetes or AWS EKS, ECS or Fargate.
- Logging & Monitoring : The application logs and metrics stored in postgres database. The logs are subscribed too using nestjs Event Emitter library.
Clone the repository
git clone https://github.com/wasswarichard/Web-Service-Logging.git
cd into the repository
cd HTTP-Web-Service-Logging
create a .env file and update the environment variables
DATABASE_HOST=postgres // this is the container database host
DATABASE_PORT=
DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_NAME=
JWT_SECRET=
Inside the repository run
docker-compose up --build
npm install
npm run start
The Backend server will start on
http://localhost:3000
Backend:
The application exposes the following endpoints:
POST /api/users/register
: Register a new user.
{
"email": "johndoe@gmail.com",
"password": "test1234567",
"role": "ADMIN" //optional enum value (ADMIN, USER)
}
{
"message": "User registered successfully",
"userId": 5
}
POST /api/users/login
: Authenticate a user and return access token.
{
"email": "johndoe@gmail.com",
"password": "test1234567",
}
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImpvaG5kb2VAZ21haWwuY29tIiwic3ViIjo0LCJpYXQiOjE3Mjc2OTQ1ODh9.c4n0TX77zAj2Svohy3RRho9rEnTzlYKzRzz__YQeEQM"
}
GET /api/logs/report
: Returns a list of the logs.
{
"infoCount": 11,
"warningCount": 0,
"errorCount": 0,
"messageWithUrlCount": 0
}