Welcome to filebased-hono! This tool helps you manage file-based routing easily for your web applications using Hono. Follow these steps to get started.
To get the latest version of filebased-hono, visit this page to download: Releases Page.
npm install filebased-hono
# or
yarn add filebased-hono
# or
pnpm add filebased-hono
To run filebased-hono, ensure you have:
filebased-hono scans the src/routes directory in your project. It identifies every file, such as get.ts, post.ts, etc., and automatically integrates them into a single Hono application instance.
A simple example of using filebased-hono is as follows:
// src/index.ts
import { createApp } from 'filebased-hono';
import { createHono } from 'filebased-hono/factory';
const app = createApp({
app: createHono().basePath('/'),
initializer: (app) => {
app.use('*', async (c, next) => {
console.log(`[request] ${c.req.method} ${c.req.path}`);
await next();
});
},
});
export default app;
To create routes, simply name your files according to the HTTP method they handle. Place them in the src/routes directory. For example, if you create a file called get.ts, it will respond to GET requests.
Each file should export a default function. This function acts as the handler for the specific route. Subdirectories can also be used to create organized URL segments.
Hereβs how your folder structure could look:
src/
βββ routes/
βββ get.ts
βββ topics/
βββ post.ts
In this example, the GET request to /topics will be handled by get.ts, and the POST request to /topics will be handled by post.ts.
filebased-hono helps streamline routing for web applications, allowing users to define routes using file names instead of additional configuration.
No, filebased-hono is designed to simplify routing. Basic familiarity with creating files and running commands will suffice.
Feel free to create an issue on the GitHub repository page if you encounter problems or have suggestions. Contributions are always welcome!
Join our community for support, tips, and updates. Connect with other users and contributors through the GitHub Issues page.
We plan to enhance filebased-hono with:
Keep an eye on our Releases Page for future updates and new features!
filebased-hono is open-source and available under the MIT License. You can freely modify and distribute it as needed.
Thank you for choosing filebased-hono to simplify your web routing needs!