Skip to content

[Bug] Routes with .domain() are flattened into root and lose domain metadata in registry #85

@lncitador

Description

@lncitador

Description

When defining routes with a specific domain in AdonisJS (v7), the tuyau registry generator ignores the domain property. This results in:

  1. All routes being grouped under a flat routes object without domain distinction.
  2. urlFor generating relative paths (e.g., /v1/teste) that fail when the application expects a specific subdomain (e.g., api.localhost).
  3. Type definitions not reflecting the domain constraints of the routes.

Reproduction

In start/routes.ts:

router
  .get('teste', ctx => {
    return ctx.response.json({ message: 'Hello World' })
  })
  .domain('api')
  .prefix('v1')
  .as('api.v1.teste')

Output of node ace list:routes --json:

[
  {
    "domain": "root",
    "routes": [ ... ]
  },
  {
    "domain": "api",
    "routes": [
      {
        "name": "api.v1.teste",
        "pattern": "/v1/teste",
        "methods": ["GET"],
        ...
      }
    ]
  }
]

Generated .adonisjs/client/registry/index.ts:

const routes = {
  // ... other routes
  'api.v1.teste': {
    methods: ["GET","HEAD"],
    pattern: '/v1/teste',
    tokens: [...],
    types: placeholder as Registry['api.v1.teste']['types'],
  },
} as const satisfies Record<string, AdonisEndpoint>

Note that there is no domain property in the generated routes object for api.v1.teste.

Environment

  • @tuyau/core: 1.0.0-beta.9
  • @adonisjs/core: 7.0.0-next.16
  • Node.js: 25.0.3

Expected Behavior

The generated registry should include domain information for each route, and urlFor should respect these domains when generating URLs (potentially including the domain in the output if it differs from the current one).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions