-
Notifications
You must be signed in to change notification settings - Fork 0
Demo - [Guidelines] - Public API route + logging user data + no unit test for new service #99
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
Conversation
PR Review ❌ Security: Update Generated by Firstmate to make sure you can focus on coding new features. |
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' function, which poses a security risk by allowing unauthorized access. Update the route to include the middleware as follows:
router.route("/user-data/:id").get(grantAccessByPermissionMiddleware([API_PERMISSIONS.PUBLIC_ENDPOINT]), exampleController.getById);
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.
import exampleRepo from "../repos/exampleRepo.js" | ||
import logger from "./utils/logger.js"; | ||
|
||
export class NewService { | ||
|
||
async getById(id) { | ||
logger.info("Getting data by ID.") | ||
return await exampleRepo.getById(id); | ||
} | ||
|
||
async getDataFromRepo(id) { | ||
return await exampleRepo.getData(id); | ||
} | ||
|
||
|
||
} | ||
|
||
export default new NewService(); |
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.
Your service functions getById
and getDataFromRepo
in newService.js
lack unit tests, which should be implemented in the test folder as per the guidelines. Ensure to create corresponding tests in a file like test/test-newService.js
. Here's a simple test structure you could use:
import NewService from '../src/services/newService.js';
describe('NewService', () => {
it('should get data by ID', async () => {
// Test implementation here
});
});
366d66e
to
5bade6d
Compare
FirstMate is reviewing your PR:
Live status: |
5bade6d
to
53fe48a
Compare
FirstMate is reviewing your PR:
Live status: |
💡 PR Summary generated by FirstMate
New API Route and User Data Logging Implementation
Changes:
New API Route:
/user-data/:id
route inexampleRouter.js
to fetch user data.New Service Class:
NewService
class innewService.js
for handling user data retrieval.getById
andgetDataFromRepo
methods with logging.Logging Enhancements:
ExampleService
andNewService
to track user data access.CI Pipeline Update:
.github/workflows/firstmate.yaml
to run tests after package installation.TLDR: This PR adds a new API route for user data, implements a new service for data retrieval with logging, and updates the CI pipeline to include tests. Focus on the new route and service implementations.
Generated by FirstMate and automatically updated on every commit.