Routes Directory

This directory contains modular route handlers for the API.

Current Routes

  • favicon.ts: Handles the /favicon endpoint for extracting favicons from URLs

Adding New Routes

To add a new route:

  1. Create a new file in this directory (e.g., myRoute.ts)
  2. Use the following template:
import { Hono } from "https://esm.sh/hono@3.11.7"; // Create a router for the endpoint const router = new Hono(); // Define your routes router.get("/", (c) => { // Handler logic return c.json({ message: "Your response" }); }); router.post("/", async (c) => { // Handler logic for POST const body = await c.req.json(); // Process the request return c.json({ result: "Your response" }); }); // Export the router export default router;
  1. Import and mount your router in the main index.tsx file:
import myRouter from "./routes/myRoute.ts"; // Mount the router app.route("/my-route", myRouter);

This modular approach helps keep the codebase organized and maintainable as the API grows.