import type { Env } from 'hono' import type { BlankEnv, BlankSchema, Schema } from 'hono/types' import * as Route from './Route.js' export function Router< env extends Env = BlankEnv, schema extends Schema = BlankSchema, basePath extends string = '/', >(options: Router.Options = {}) { const handler = new Router.Inner(options) handler.hono.get('/', (c) => c.text(` █▀█ █▀█ █▀█ ▀█▀ █▀█ █▀▀ █▄█ █▀▄ █ █▄█ `), ) return handler } export namespace Router { export type Options = Omit< Inner.ConstructorOptions, 'defaultPath' > export class Inner< env extends Env = BlankEnv, schema extends Schema = BlankSchema, basePath extends string = '/', > extends Route.from.Inner { /** * `.route()` allows grouping other Porto handlers in routes. * * @example * TODO * * @param path - base Path * @param app - other Porto handler * @returns routed Porto handler */ route< path extends string, env extends Env, schema extends Schema, subBasePath extends string, >( path: path, app: Route.from.Inner, ): Inner { this.hono.route(path, app.hono) return this as never } } export declare namespace Inner { type ConstructorOptions = Route.from.Inner.ConstructorOptions } }