mirror of
https://github.com/honojs/hono.git
synced 2024-11-22 02:27:49 +01:00
16f73935ef
* fix(types): allow blank env * types: blank env * fix(types): add mock binding * cleanup * Update yarn.lock * fix: bun lock conflict * revert * fix(types): update quick and tiny preset
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { HonoBase } from './hono-base'
|
|
import type { HonoOptions } from './hono-base'
|
|
import { RegExpRouter } from './router/reg-exp-router'
|
|
import { SmartRouter } from './router/smart-router'
|
|
import { TrieRouter } from './router/trie-router'
|
|
import type { BlankEnv, BlankSchema, Env, Schema } from './types'
|
|
|
|
/**
|
|
* The Hono class extends the functionality of the HonoBase class.
|
|
* It sets up routing and allows for custom options to be passed.
|
|
*
|
|
* @template E - The environment type.
|
|
* @template S - The schema type.
|
|
* @template BasePath - The base path type.
|
|
*/
|
|
export class Hono<
|
|
E extends Env = BlankEnv,
|
|
S extends Schema = BlankSchema,
|
|
BasePath extends string = '/'
|
|
> extends HonoBase<E, S, BasePath> {
|
|
/**
|
|
* Creates an instance of the Hono class.
|
|
*
|
|
* @param options - Optional configuration options for the Hono instance.
|
|
*/
|
|
constructor(options: HonoOptions<E> = {}) {
|
|
super(options)
|
|
this.router =
|
|
options.router ??
|
|
new SmartRouter({
|
|
routers: [new RegExpRouter(), new TrieRouter()],
|
|
})
|
|
}
|
|
}
|