Files
main.tsmain
What you'll learn
- Write a resource as its own Hono app in its own file, with paths relative to where it will be mounted
- Mount sub-apps with app.route(prefix, subApp) and prefix everything with basePath()
- Know the ordering rule: a sub-app's routes are copied when app.route() runs, so register them first
Press Run tests to start the app. Its log appears here.Graded endpoints
A route registered at / on an app with basePath('/api') answers at /api
The cats sub-app's / route, mounted at /cats under the base path
The sub-app's /:id route: parameters work the same inside a mounted app
The sub-app answers its own 404
A second sub-app, mounted at /owners
A nested resource route in the owners app, reading the shared data
The owners app's own 404
Nothing lives outside /api: Hono's plain 404