Skip to content

✨ Support direct route and command composition - #48

Merged
cowboyd merged 3 commits into
mainfrom
feat/direct-route-composition
Oct 9, 2026
Merged

cowboyd merged 3 commits into
mainfrom
feat/direct-route-composition

Conversation

@cowboyd

@cowboyd cowboyd commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Route definitions currently require a routes() wrapper around every group of children which is tedious and contributes to rightward drift. Allow route(), command(), and extend() to accept child definitions directly, so nesting reads like the route tree:

Before

export const app = command(
  name("simulacrum"),
  description("Run and manage local service simulators."),
  version("1.0.0"),
  toggle(name("verbose")),
  routes(
    command(
      name("serve"),
      option(name("port"), schema(z.number().default(4000))),
    ),
    route(
      name("database"),
      routes(
        command(
          name("clean"),
          toggle(name("dryRun")),
        ),
        command(name("migrate")),
      ),
    ),
  ),
);

After

export const app = command(
  name("simulacrum"),
  description("Run and manage local service simulators."),
  version("1.0.0"),
  toggle(name("verbose")),
  command(
    name("serve"),
    option(name("port"), schema(z.number().default(4000))),
  ),
  route(
    name("database"),
    command(
      name("clean"),
      toggle(name("dryRun")),
    ),
    command(name("migrate")),
  ),
);

Breaking API change: remove the public routes() export. Replace inline routes(child, other) with direct children, or use extend(child, other) for reusable groups and dynamic resolver results. Update the README, examples, and existing tests to demonstrate the replacement API.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • All tests pass (deno task test; this repository uses Deno)
  • Files are formatted (deno fmt --check)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset (@bomb.sh/router: minor)

AI-generated code disclosure

  • This PR includes AI-generated code

@pkg-pr-new

pkg-pr-new Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/router@48

commit: 6f71bd0

@cowboyd
cowboyd marked this pull request as ready for review October 8, 2026 03:43

@natemoo-re natemoo-re left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sweet! lgtm

Comment thread .changeset/direct-route-composition.md Outdated
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
@cowboyd
cowboyd force-pushed the feat/direct-route-composition branch from 6be3660 to 6f71bd0 Compare October 9, 2026 15:58
@cowboyd
cowboyd merged commit 4b42863 into main Oct 9, 2026
6 checks passed
@cowboyd
cowboyd deleted the feat/direct-route-composition branch October 9, 2026 16:04
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.

2 participants