Skip to content

New: Move route definitions to routes.json (fixes #47) - #48

Closed
taylortom with Copilot wants to merge 2 commits into
masterfrom
copilot/refactor-route-definitions
Closed

New: Move route definitions to routes.json (fixes #47)#48
taylortom with Copilot wants to merge 2 commits into
masterfrom
copilot/refactor-route-definitions

Conversation

Copilot AI commented Feb 26, 2026

Copy link
Copy Markdown

Route configuration is moving from imperative code to declarative routes.json files, consumed by loadRouteConfig in adapt-authoring-server. Since RolesModule only uses default CRUD routes, the entire route setup reduces to a single JSON file.

Update

  • Replaced this.root = 'roles' assignment and this.useDefaultRouteConfig() call in setValues() with a routes.json at the module root — loadRouteConfig now handles route registration automatically

New

  • routes.json declaring "root": "roles" — no routes array needed since all routes are inherited from AbstractApiModule defaults

Testing

  1. Run npm test — all 47 tests pass
  2. On startup, verify the roles API routes are registered at /api/roles as before
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-roles#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-roles#77) and AbstractAuthModule (PR adapt-security/adapt-authoring-roles#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

RolesModule calls useDefaultRouteConfig() in init() with no custom routes — it uses only the standard CRUD defaults.

Refactoring steps

  1. Create routes.json in the module root:
{
  "root": "roles"
}

Since this module uses only default routes, no routes array is needed — loadRouteConfig will use the defaults from AbstractApiModule.

  1. Remove imperative route setup from init():

    • Remove the useDefaultRouteConfig() call
    • Remove the root assignment if present
  2. Remove setValues override if it only existed to set root

  3. 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 use routes.json Refactor(roles): move route definitions to routes.json Feb 26, 2026
@taylortom taylortom changed the title Refactor(roles): move route definitions to routes.json New: Move route definitions to routes.json (refs #47) Feb 26, 2026
@taylortom taylortom changed the title New: Move route definitions to routes.json (refs #47) 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 #47) Feb 26, 2026
@taylortom
taylortom marked this pull request as ready for review February 26, 2026 17:44
@taylortom

Copy link
Copy Markdown
Contributor

Closing in favour of #49 which will include these changes with fixes

@taylortom taylortom closed this 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