You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor: register v1-alpha development routes by directory - #2241
Every Development endpoint PR (IN-1331 to IN-1335) had to add an import and a scope.register line to api/src/versions/v1-alpha/index.ts. With five PRs open at once, each merge put the other four into conflict and forced a rebase round. Nine more Development endpoints are still to come, plus the later groups.
What
api/src/versions/v1-alpha/index.ts loads every module under development/ with @fastify/autoload (dirNameRoutePrefix: false because route paths are absolute, forceESM: true). An endpoint PR now adds one route file and one test file and touches nothing shared, so merge order stops mattering.
api/vitest.config.ts inlines @fastify/autoload (server.deps.inline). Vitest transforms .ts imports only in project code; autoload's dynamic import runs inside node_modules and would otherwise hit Node's "Unknown file extension .ts".
api/tests/v1-alpha-autoload.test.ts pins the convention: the modules in development/ and the /v1-alpha/projects/{slug}/development/* paths in the alpha spec match one to one, filename = path leaf. A module that fails to load or registers outside the group now fails a test instead of silently dropping out of the spec.
New runtime dependency: @fastify/autoload 6.5.0 (official Fastify plugin, alongside @fastify/static and @fastify/swagger).
Verification
Route tree identical before and after under all three runtimes:
tsx dev server: /v1-alpha/projects/:slug/development/issues-resolution registered
compiled dist/ under plain Node: same
Adding an endpoint from now on
Create api/src/versions/v1-alpha/development/<path-leaf>.ts with a default-exported Fastify plugin that registers /projects/:slug/development/<path-leaf>, and its test under api/tests/. Nothing else.
Follow-up
The four open endpoint PRs (#2238, #2240, #2239, #2237) are rebased onto this branch so their index.ts edits disappear; they retarget to main when this merges.
Jira: IN-1348
main
refactor: register v1-alpha development routes by directory 👈
The reason will be displayed to describe this comment to others. Learn more.
I checked the autoload config against the manual registration it replaces, and traced through the new test to confirm it asserts a real invariant (filename to route-path-leaf), not something trivially true. Old import and register call are gone. None of the dependent PR's route files show up in this diff. LGTM.
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🔵 Needs a closer look
The convention test can miss routes containing unexpected intermediate path segments.
Review effort: Balanced Findings: None
Files not reviewed (1)
pnpm-lock.yaml: Generated file
Previously missed (1)
In code that hasn't changed since last review
Path validation ignores extra directory segments
api/tests/v1-alpha-autoload.test.ts:36
Stripping everything before the final slash lets /development/extra/<filename> pass despite the documented exact-path convention. Compare complete paths derived from each filename instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Every Development endpoint PR (IN-1331 to IN-1335) had to add an import and a
scope.registerline toapi/src/versions/v1-alpha/index.ts. With five PRs open at once, each merge put the other four into conflict and forced a rebase round. Nine more Development endpoints are still to come, plus the later groups.What
api/src/versions/v1-alpha/index.tsloads every module underdevelopment/with@fastify/autoload(dirNameRoutePrefix: falsebecause route paths are absolute,forceESM: true). An endpoint PR now adds one route file and one test file and touches nothing shared, so merge order stops mattering.api/vitest.config.tsinlines@fastify/autoload(server.deps.inline). Vitest transforms.tsimports only in project code; autoload's dynamic import runs inside node_modules and would otherwise hit Node's "Unknown file extension .ts".api/tests/v1-alpha-autoload.test.tspins the convention: the modules indevelopment/and the/v1-alpha/projects/{slug}/development/*paths in the alpha spec match one to one, filename = path leaf. A module that fails to load or registers outside the group now fails a test instead of silently dropping out of the spec.@fastify/autoload6.5.0 (official Fastify plugin, alongside@fastify/staticand@fastify/swagger).Verification
Route tree identical before and after under all three runtimes:
tsc-check,lint,format:check/v1-alpha/projects/:slug/development/issues-resolutionregistereddist/under plain Node: sameAdding an endpoint from now on
Create
api/src/versions/v1-alpha/development/<path-leaf>.tswith a default-exported Fastify plugin that registers/projects/:slug/development/<path-leaf>, and its test underapi/tests/. Nothing else.Follow-up
The four open endpoint PRs (#2238, #2240, #2239, #2237) are rebased onto this branch so their
index.tsedits disappear; they retarget tomainwhen this merges.Jira: IN-1348
main