Description
To avoid breaking changes for merchants, we need a robust API versioning strategy. Instead of URL versioning (e.g. /v1/), we will implement Header-based versioning (Accept-Version: 1).
Requirements and context
- Create a middleware in
backend/src/app.js that detects the version header.
- Structure routes into
src/routes/v1 and src/routes/v2 respectively.
- Default to
v1 if no header is provided.
Suggested execution
- Fork the repo and create a branch: git checkout -b feature/api-versioning
- Implement changes:
- Refactor
createApp to mount version-specific routers.
- Implement a fallback mechanism for shared logic.
- Test and commit:
- Use
curl -H "Accept-Version: 1" to verify routing.
Example commit message
arch: implement header-based API versioning
Guidelines
- Complexity: High (200 points)
Description
To avoid breaking changes for merchants, we need a robust API versioning strategy. Instead of URL versioning (e.g.
/v1/), we will implement Header-based versioning (Accept-Version: 1).Requirements and context
backend/src/app.jsthat detects the version header.src/routes/v1andsrc/routes/v2respectively.v1if no header is provided.Suggested execution
createAppto mount version-specific routers.curl -H "Accept-Version: 1"to verify routing.Example commit message
arch: implement header-based API versioning
Guidelines