Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable to add sub-applications in a method chain format by using route() #947

Closed
usualoma opened this issue Mar 3, 2023 Discussed in #945 · 1 comment
Closed

Enable to add sub-applications in a method chain format by using route() #947

usualoma opened this issue Mar 3, 2023 Discussed in #945 · 1 comment

Comments

@usualoma
Copy link
Member

usualoma commented Mar 3, 2023

I, too, think it would be better to be able to specify this in the method chaining.

Discussed in https://github.com/orgs/honojs/discussions/945

Originally posted by kissge March 3, 2023
I've tried to use route like this, but couldn't make it work:

// api/photos/photos.routes.ts
const routes = new Hono().get('/list', (c) => c.jsonT({ photos: 0 }))
export default routes
// api/videos/videos.routes.ts
const routes = new Hono().get('/list', (c) => c.jsonT({ videos: 0 }))
export default routes
// api/routes.ts
import photos from './photos/photos.routes.ts'
import videos from './photos/photos.routes.ts'
const routes = new Hono().route('/photos', photos).route('/videos', videos)
export default routes
// api/index.ts
import routes from './routes'
const app = new Hono()
    .route('/', routes)
    .use(...)
    .use(...)
    .use(...)

Is this usage expected? Does hono support it? Any hint would be appreciated.

kissge@7e35ff5

@usualoma usualoma changed the title Using multiple or nested Hono.prototype.route Enable to add sub-applications in a method chain format by using route() Mar 3, 2023
@usualoma
Copy link
Member Author

Implemented in #948 and released in v3.1.0.

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

No branches or pull requests

1 participant