v0.1.3
This commit is contained in:
parent
b9b5641b26
commit
65ee95ca0c
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@_because/hype",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"module": "src/index.tsx",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,10 @@ export type HypeProps = {
|
|||
reset?: boolean
|
||||
prettyHTML?: boolean
|
||||
layout?: boolean
|
||||
router?: boolean
|
||||
}
|
||||
|
||||
type InternalProps = HypeProps & { _isRouter?: boolean }
|
||||
|
||||
export type SSEHandler<E extends Env> = (
|
||||
send: (data: unknown, event?: string) => Promise<void>,
|
||||
c: Context<E>
|
||||
|
|
@ -41,13 +42,18 @@ export class Hype<
|
|||
middlewareRegistered = false
|
||||
routesRegistered = false
|
||||
|
||||
constructor(props?: HypeProps & ConstructorParameters<typeof Hono<E, S, BasePath>>[0]) {
|
||||
constructor(props?: InternalProps & ConstructorParameters<typeof Hono<E, S, BasePath>>[0]) {
|
||||
super(props)
|
||||
|
||||
this.props = props ?? {}
|
||||
if (!this.props.router)
|
||||
if (!props?._isRouter) {
|
||||
this.registerMiddleware()
|
||||
}
|
||||
}
|
||||
|
||||
static router<E extends Env = Env>(): Hype<E> {
|
||||
return new Hype<E>({ _isRouter: true })
|
||||
}
|
||||
|
||||
sse(path: string, handler: SSEHandler<E>) {
|
||||
return this.get(path, (c) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user