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