refactor: establish canonical v1 web API - #28
Conversation
Includes branch changelog.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11a6fc42bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,7 @@ | |||
| export function deprecatedApi(successorPath: string) { | |||
| return (request, response, next): void => { | |||
| response.setHeader('Deprecation', 'true'); | |||
There was a problem hiding this comment.
Emit a valid Deprecation structured date
The Deprecation field defined by RFC 9745 is an HTTP Structured Field Date such as @1788397200; the boolean value true is invalid. Standards-aware clients will therefore fail to parse this header and may not recognize that /api and /api2 are deprecated. Send an appropriate Unix timestamp in the structured-date format and update the unit test accordingly.
Useful? React with 👍 / 👎.
| this.app.use('/api', deprecatedApi('/api/v1'), (new API(this)).config()); | ||
| this.app.use('/admin/api2', deprecatedApi('/admin/api/v1'), (new API2(this)).adminConfig()); | ||
| this.app.use('/admin/api', deprecatedApi('/admin/api/v1'), (new API(this)).adminConfig()); |
There was a problem hiding this comment.
Keep legacy middleware from matching canonical v1 requests
When the canonical router calls next() because a /api/v1 path or method is unknown, this later /api mount also prefix-matches the same request and applies the deprecation middleware. For example, POST /api/v1/status returns a final error carrying headers that say the canonical API itself is deprecated; the analogous /admin/api mount has the same problem. Exclude /api/v1 from the alias middleware or mount the aliases so they cannot consume canonical fallthroughs.
Useful? React with 👍 / 👎.
Summary
Defines one canonical, versioned HTTP contract.
/api/v1and/admin/api/v1/api2as a compatibility adapterCHANGELOG.mdStack
Depends on
refactor/separate-admin-routes(#2). This is web #3.