-
Notifications
You must be signed in to change notification settings - Fork 0
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
Demo - [Guidelines] - Public API route + logging user data + no unit test for new service #104
Conversation
PR Review ❌ Code quality & structure: Method name 'getExcetutedDocuments' contains a typo; should be 'getExecutedDocuments' for consistency. Generated by Firstmate to make sure you can focus on coding new features. |
async getExcetutedDocuments(id) { | ||
return await exampleRepo.getById(id) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name getExcetutedDocuments
contains a typo; it should be getExecutedDocuments
for consistency and clarity. Additionally, consider implementing retries for external API calls in this method to enhance reliability. Here's a simple example of how to implement retries:
async getExecutedDocuments(id, retries = 3) {
try {
return await exampleRepo.getById(id);
} catch (error) {
if (retries > 0) {
return this.getExecutedDocuments(id, retries - 1);
}
throw error;
}
}
async getExcetutedDocuments(id) { | ||
return await exampleRepo.getById(id) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name getExcetutedDocuments
contains a spelling mistake; it should be corrected to getExecutedDocuments
. Additionally, consider implementing retries for the external API calls in getUserData
to enhance reliability. Here's how you can implement a simple retry mechanism:
async function retry(fn, retries = 3) {
for (let i = 0; i < retries; i++) {
try {
return await fn();
} catch (error) {
if (i === retries - 1) throw error;
}
}
}
const user = await exampleRepo.getById(id); | ||
logger.info(user.data); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const user = await exampleRepo.getById(id); | ||
logger.info(user.data); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging user data at the info level in getUserData
may expose sensitive information. Instead, use a debug level for logging or mask the sensitive data before logging. For example, you could modify the logging line as follows:
- logger.info(user.data);
+ logger.debug({ id: user.id, name: user.name }); // Masking sensitive data
router.route("/user-data/:id").get( exampleController.getById) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The route '/user-data/:id' lacks the 'grantAccessByPermissionMiddleware', which can lead to unauthorized access. You should add the middleware to ensure proper permission checks like this:
+ router.route("/user-data/:id").get(grantAccessByPermissionMiddleware([API_PERMISSIONS.USER_DATA]), exampleController.getById)
This will help secure the route according to the guidelines.
💡 PR Summary generated by FirstMate
Overview: Introduced a new public API route for user data and added logging functionality.
Changes:
New API Route:
/user-data/:id
endpoint inexampleRouter.js
to fetch user data.Logging Enhancements:
ExampleService
andNewService
to track user data retrieval.Workflow Updates:
.github/workflows/firstmate.yaml
to includepnpm test
after package installation.TLDR: New public API route for user data with logging added; review the router and service changes for functionality.
Generated by FirstMate and automatically updated on every commit.