UNPKG

bun-routes

Version:

Bun Routes is a lightweight, type-safe router built for Bun with zero dependencies

21 lines (20 loc) 773 B
import type { RouterTypes } from "bun"; /** * Creates a router that manages route handlers. * * This function returns an object with two methods: * - `add`: Registers a new route. * - `getRoutes`: Returns all registered routes. * * The router ensures that duplicate route definitions (same HTTP method and path) * are not allowed. If a duplicate is detected, an error is thrown. * * @returns An object with `add` and `getRoutes` functions. */ export declare function createRoutes(): { add: <T extends string>(route: [T, RouterTypes.RouteHandlerObject<T>]) => { add: /*elided*/ any; getRoutes: () => Record<string, RouterTypes.RouteHandlerObject<string>>; }; getRoutes: () => Record<string, RouterTypes.RouteHandlerObject<string>>; };