External routes file #1573
Answered
by
raphaelkieling
sistematico
asked this question in
Q&A
-
How to use Hono with external routes file? index.ts
routes/index.ts
But this doesn't seem to be correct. |
Beta Was this translation helpful? Give feedback.
Answered by
raphaelkieling
Oct 14, 2023
Replies: 1 comment
-
It should work as well, but the doc itself give you the option to use grouping: https://hono.dev/api/routing#grouping Your final code would be something like: import { Hono } from "hono";
import { serve } from "@hono/node-server";
import book from "./routes";
const app = new Hono();
app.route("/books", book);
app.get("/", (c) => c.text("API OK")); import { Hono } from "hono";
const book = new Hono();
book.get("/test", (c) => {
return c.text("test");
});
export default book; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sistematico
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should work as well, but the doc itself give you the option to use grouping: https://hono.dev/api/routing#grouping
Your final code would be something like: