SFU-Blueprint / Pedals

Apache License 2.0
2 stars 0 forks source link

/api/access-code Refactor and Testing #59

Open dangminhduc1101 opened 2 months ago

dangminhduc1101 commented 2 months ago

Problem

Although the access code functionality is implemented, it is not yet fully complete. Some issues include:

  1. The access code functionality is currently split across two separate routes: api/change-access-code/route.ts and api/validate-access-code/route.ts. We should refactor this into a single route, api/access-code/route.ts, where a POST request will handle access code validation, and a PATCH request will handle access code changes.
  2. Currently, it’s possible to change the access code using an old code (not the current one). This behavior should be corrected to prevent that.
  3. While the functionality is stable, no tests are in place yet.

Instructions

  1. Pull the latest changes from the develop branch.
  2. Start the server by running npm run dev (if necessary, navigate to the src/ folder and run npm ci first).
  3. Refactor the access code routes by consolidating them into api/access-code/route.ts. Make sure to update the corresponding front-end code to reflect these changes.
  4. Write comprehensive tests for api/access-code/route.ts. Ensure all possible cases from the original routes are covered and include detailed comments for clarity. Your code formatting will serve as a reference for other test suites.
  5. Submit a pull request and tag @dangminhduc1101 for review.