Skip to content

New: Move route definitions to routes.json (fixes #96)#97

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/refactor-route-definitions-json
Draft

New: Move route definitions to routes.json (fixes #96)#97
Copilot wants to merge 3 commits intomasterfrom
copilot/refactor-route-definitions-json

Conversation

Copy link

Copilot AI commented Feb 26, 2026

Migrates ContentModule's custom route definitions from imperative setValues() code to a declarative routes.json file, aligning with the loadRouteConfig pattern introduced in adapt-authoring-server.

Update

  • setValues() now only sets collectionName and schemaName; root and route config are driven by routes.json
  • Removed apidefs import — meta was only used in the imperative route objects

New

  • routes.json declares the /insertrecursive and /clone POST routes with write:{scope} permissions; default CRUD routes are prepended automatically by loadRouteConfig

Testing

  1. Start the authoring tool and verify POST /api/content/insertrecursive and POST /api/content/clone are registered and accessible
  2. Confirm default CRUD routes (/, /:_id, /query, /schema) still function
  3. Run npm test
Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor: Move route definitions to routes.json</issue_title>
<issue_description>## Context

Route definitions are moving from imperative code to declarative routes.json files. The loadRouteConfig function in adapt-authoring-server (PR adapt-security/adapt-authoring-content#58) now handles reading routes.json, resolving handler strings to bound methods, validating against a schema, and merging with default routes.

AbstractApiModule (PR adapt-security/adapt-authoring-content#77) and AbstractAuthModule (PR adapt-security/adapt-authoring-content#68) both call loadRouteConfig in setValues() with a defaults option, so consumer modules that provide a routes.json automatically get the base default routes prepended.

Current state

ContentModule calls useDefaultRouteConfig() then pushes two custom routes:

  • POST /insertrecursivehandleInsertRecursive (permission: write:content)
  • POST /clonehandleClone (permission: write:content)

Refactoring steps

  1. Create routes.json in the module root:
{
  "root": "content",
  "routes": [
    {
      "route": "/insertrecursive",
      "handlers": { "post": "handleInsertRecursive" },
      "permissions": { "post": ["write:{scope}"] }
    },
    {
      "route": "/clone",
      "handlers": { "post": "handleClone" },
      "permissions": { "post": ["write:{scope}"] }
    }
  ]
}

Default CRUD routes (/, /:_id, /query, /schema) are automatically prepended by loadRouteConfig.

  1. Remove imperative route setup from init():

    • Remove the useDefaultRouteConfig() call
    • Remove the this.routes.push(...) calls
    • Remove root and permission setup code
  2. Test by running npm test and verifying routes are registered correctly at startup</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: taylortom <1059083+taylortom@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor route definitions to routes.json Refactor(content): move route definitions to routes.json Feb 26, 2026
@taylortom taylortom changed the title Refactor(content): move route definitions to routes.json New: Move route definitions to routes.json (refs #96) Feb 26, 2026
@taylortom taylortom changed the title New: Move route definitions to routes.json (refs #96) New: Move route definitions to routes.json Feb 26, 2026
@taylortom taylortom changed the title New: Move route definitions to routes.json New: Move route definitions to routes.json (fixes #96) Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Move route definitions to routes.json

2 participants