Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2790 - Update API Access Logs #4334

Merged
merged 15 commits into from
Feb 11, 2025
Merged

#2790 - Update API Access Logs #4334

merged 15 commits into from
Feb 11, 2025

Conversation

dheepak-aot
Copy link
Collaborator

@dheepak-aot dheepak-aot commented Feb 10, 2025

Update API Access Logs

Implementation of Access logging with NestJS Middleware

  • Created a middleware to log all the requests coming to API, except the health check requests using NestJS Middleware

Resource: https://docs.nestjs.com/middleware

  • Log Http Method, URL ,Client IP ,User GUID(on authenticated endpoints) and User Agent Header for all requests to API.

Authenticated API access logs

image

Non-Authenticated API access logs

image

Refactor health controller

  • Refactored the class name and endpoint of health controller(Previously known as app controller)

Centralization

  • Centralized the code to get client IP from HTTP request.

@dheepak-aot dheepak-aot added the SIMS-Api SIMS-Api label Feb 10, 2025
@dheepak-aot dheepak-aot self-assigned this Feb 10, 2025
@dheepak-aot dheepak-aot marked this pull request as ready for review February 10, 2025 23:27
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes, please take a look at the comments.

/**
* Logs access information of every request.
* @param request http request.
* @param _response http request.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to http reponse.

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes, the middleware is a great addition and can help guide other development in the future. Look good 👍

Copy link

Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 22.11% ( 3914 / 17704 )
Methods: 9.96% ( 226 / 2268 )
Lines: 25.46% ( 3380 / 13276 )
Branches: 14.26% ( 308 / 2160 )

Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 65.59% ( 589 / 898 )
Methods: 59.63% ( 65 / 109 )
Lines: 68.72% ( 468 / 681 )
Branches: 51.85% ( 56 / 108 )

Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 87.58% ( 1418 / 1619 )
Methods: 84.66% ( 160 / 189 )
Lines: 89.72% ( 1170 / 1304 )
Branches: 69.84% ( 88 / 126 )

Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 68.48% ( 6150 / 8981 )
Methods: 66.35% ( 761 / 1147 )
Lines: 72.24% ( 4810 / 6658 )
Branches: 49.23% ( 579 / 1176 )

@dheepak-aot dheepak-aot added the Devops Devops label Feb 11, 2025
@bidyashish
Copy link
Collaborator

Please add any sample error logs, if user not logged in and without correct permission.

Copy link
Collaborator

@bidyashish bidyashish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Devops Devops SIMS-Api SIMS-Api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants