Skip to content

New: Move route definitions to routes.json (fixes #10)#11

Closed
Copilot wants to merge 2 commits intomasterfrom
copilot/refactor-route-definitions-json
Closed

New: Move route definitions to routes.json (fixes #10)#11
Copilot wants to merge 2 commits intomasterfrom
copilot/refactor-route-definitions-json

Conversation

Copy link

Copilot AI commented Feb 26, 2026

Replaces imperative route setup in UserGroupsModule with a declarative routes.json, aligning with the ecosystem-wide refactor where AbstractApiModule.setValues() calls loadRouteConfig automatically.

Update

  • Removed this.root assignment and this.useDefaultRouteConfig() call from setValues() — both are now handled by AbstractApiModule via loadRouteConfig

New

  • Added routes.json declaring root: "usergroups"; no routes array needed since this module uses only the default CRUD routes provided by AbstractApiModule

Testing

  1. Run npm test — all tests pass (pre-existing failure for missing adapt-authoring-api dev dependency is unrelated)
  2. Verify at startup that CRUD routes are registered under /usergroups
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-usergroups#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-usergroups#77) and AbstractAuthModule (PR adapt-security/adapt-authoring-usergroups#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

UserGroupsModule 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": "usergroups"
}

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)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: taylortom <1059083+taylortom@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor route definitions to use routes.json refactor: move route definitions to routes.json Feb 26, 2026
@taylortom taylortom changed the title refactor: move route definitions to routes.json New: Move route definitions to routes.json (refs #10) Feb 26, 2026
@taylortom taylortom changed the title New: Move route definitions to routes.json (refs #10) 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 #10) Feb 26, 2026
@taylortom taylortom marked this pull request as ready for review February 26, 2026 17:44
@taylortom
Copy link
Contributor

Closing in favour of #12 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