Skip to content

feat(routing): add route groups#147

Merged
imdhemy merged 8 commits into2.xfrom
pr4-route-groups
Mar 25, 2026
Merged

feat(routing): add route groups#147
imdhemy merged 8 commits into2.xfrom
pr4-route-groups

Conversation

@imdhemy
Copy link
Copy Markdown
Member

@imdhemy imdhemy commented Mar 25, 2026

Q A
License GPLv3
Issue Closes #140

Summary

This PR adds RouteGroup(...) to the function-first routing API.

Route groups make it possible to compose routes with shared path prefixes, name prefixes, middleware, and route-level configuration while keeping the routing model explicit and function-first. They also provide a clean way to enrich named helper routes without expanding the HTTP verb helper signatures.

Documentation

Documentation updates are covered in the docs PR:

koala-ts/koala-ts.github.io#12

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds route grouping support to the function-first routing API by introducing RouteGroup(...) and a normalization step that flattens grouped routes into concrete RouteDefinitions before registration/validation.

Changes:

  • Introduce RouteGroup / RouteSource and normalize grouped/nested routes (prefixes, name prefixes, middleware, and per-route overlays).
  • Refactor route registration pipeline into normalization → expansion → validation.
  • Add unit + integration/e2e tests covering grouped routing behavior and duplicate detection.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/function-first-routing.e2e.test.ts Adds E2E coverage for grouped routes, middleware order, overlays, nesting, and duplicate detection.
src/routing/validate-route-definitions.ts Centralizes duplicate name/signature validation.
src/routing/validate-route-definitions.test.ts Adds unit tests for validation behavior.
src/routing/route-source.ts Introduces RouteSource union (route or group).
src/routing/route-registration.ts Defines the expanded registration shape used for router registration + signature validation.
src/routing/route-group.ts Adds RouteGroup definition + options (prefix/namePrefix/middleware/routeConfig).
src/routing/route-group.test.ts Unit tests for route group definition creation.
src/routing/resolve-route-options.ts Extracts/centralizes route options resolution + merging for overlays.
src/routing/resolve-route-options.test.ts Unit tests for resolving/merging route options.
src/routing/register-routes.ts Updates registrar to accept RouteSource[] and use normalize/expand/validate pipeline.
src/routing/register-routes.test.ts Adds grouped-route registration test and grouped-duplicate signature test.
src/routing/normalize-route-sources.ts Implements flattening/normalization of route groups (path/name/middleware + overlays).
src/routing/normalize-route-sources.test.ts Comprehensive tests for normalization, nesting, overlays, and path edge cases.
src/routing/index.ts Exports RouteGroup and new public types.
src/routing/expand-route-definitions.ts Extracts route expansion (methods + body parsing middleware).
src/routing/expand-route-definitions.test.ts Unit tests for expansion behavior.
src/routing/create-route-definition.ts Refactors to use resolveRouteOptions helper.
src/application/create-application.test.ts Adds create-app test that uses grouped routes.
src/Config/types.ts Widens KoalaConfig.routes from RouteDefinition[] to RouteSource[].

Comment thread src/routing/normalize-route-sources.ts
@imdhemy imdhemy merged commit ade02bc into 2.x Mar 25, 2026
1 check passed
@imdhemy imdhemy deleted the pr4-route-groups branch March 25, 2026 11:38
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.

Route Groups

2 participants