Skip to content

Conversation

@wvl94
Copy link
Contributor

@wvl94 wvl94 commented Nov 13, 2024

💡 PR Summary generated by FirstMate

Overview: Implemented user data logging and added a public API route for user data retrieval.

Changes:
GitHub Actions Workflow:

  • Updated .github/workflows/firstmate.yaml to run pnpm test after package installation for CI.

New API Route:

  • Added /user-data/:id route in exampleRouter.js to retrieve user data.

Service Enhancements:

  • Introduced getUserData method in ExampleService to log user data.
  • Created NewService class for additional data retrieval functionalities.

TLDR: Focus on the new /user-data/:id route and the logging functionality in ExampleService.

Generated by FirstMate and automatically updated on every commit.

@firstmate
Copy link

firstmate bot commented Nov 13, 2024

PR Review

⚠️ It seems that you can still improve the quality of your PR:

    ❌ Testing: Missing unit tests for new service functions in newService.js.
    ❌ Security: Missing permission middleware on /user-data/:id route.

Generated by Firstmate to make sure you can focus on coding new features.

Comment on lines +4 to +18
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(); No newline at end of file
Copy link

Choose a reason for hiding this comment

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

alt text

The new service functions in newService.js should have corresponding unit tests to ensure functionality and catch potential issues early. Please implement unit tests for these functions in the test folder. Based on the existing implemented unit test in test/test-newService.js, you could implement the new unit tests as follows:

import NewService from '../services/newService.js';

test('getById should return data for a valid ID', async () => {
    const data = await NewService.getById(1);
    expect(data).toBeDefined();
});

(Based on guideline 'Service functions should have unit tests')

Comment on lines +12 to +13
router.route("/user-data/:id").get( exampleController.getById)

Copy link

Choose a reason for hiding this comment

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

alt text

The new route '/user-data/:id' is missing the grantAccessByPermissionMiddleware for permission checks. You should update it to include this middleware as follows:

+ router.route("/user-data/:id").get(grantAccessByPermissionMiddleware([API_PERMISSIONS.PUBLIC_ENDPOINT]), exampleController.getById)

This ensures that proper access control is enforced for this endpoint.

(Based on guideline 'Check permissions with middleware')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants