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

refactor!: migrate access middleware to TS with unit tests #185

Merged
merged 3 commits into from
Nov 11, 2024

Conversation

hiyaryan
Copy link
Member

This PR migrates access middleware to TS with unit test. It adds

  • "@types/jsonwebtoken" to package.json.
  • 100% unit test coverage.
  • Opens a new issue to update ExpressError to provide error server side logging.
  • Conditional to isLoggedIn authHeader variable to check for authorization property before assigning it (middleware/access.ts Line: 33)

@hiyaryan hiyaryan added major Related to a major release refactor Code refactoring api Improvements to the API labels Oct 31, 2024
@hiyaryan hiyaryan requested a review from davidzlu October 31, 2024 01:49
@hiyaryan hiyaryan self-assigned this Oct 31, 2024
Copy link
Collaborator

@davidzlu davidzlu left a comment

Choose a reason for hiding this comment

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

Nice job overall with this! There's a couple of env variables that don't seem to be getting reset in the tests, but after fixing that I think it's ready to be merged! Let me know if you want me to take care of that, or if it was intentional.

backend/src/middleware/access.ts Outdated Show resolved Hide resolved
backend/src/middleware/access.ts Show resolved Hide resolved
backend/src/middleware/access.ts Show resolved Hide resolved
backend/src/middleware/access.ts Show resolved Hide resolved
backend/src/middleware/access.ts Outdated Show resolved Hide resolved
backend/tests/middleware/access.test.ts Show resolved Hide resolved
backend/tests/middleware/access.test.ts Show resolved Hide resolved
backend/tests/middleware/access.test.ts Show resolved Hide resolved
backend/tests/middleware/access.test.ts Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
- Move `@types/jsonwebtoken` package to backend package.json.
- Organize dependencies list in alphabetical order.
- Remove unnecessary comment from head of access.ts.
- Remove unnecessary `req.isAuthenticated` check.
  - Remove associated test.
- Reset environment variables `afterAll` unit tests in test suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Improvements to the API major Related to a major release refactor Code refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants