rajt
Version:
A serverless bundler layer, fully typed for AWS Lambda (Node.js and LLRT) and Cloudflare Workers.
18 lines (14 loc) • 485 B
text/typescript
import type {
Context, MiddlewareHandler, Next,
IRequest,
} from './types'
export type MiddlewareType = MiddlewareHandler | Middleware | (new () => Middleware)
export class Middleware {
static factory?: Function
static opts?: object | any[]
static path: string = '*'
static async handle(c: Context, next: Next): Promise<void> {
await next()
}
}
export const toHonoMiddleware = (mw: MiddlewareHandler) => async (req: IRequest, next: Next) => await mw(req.cx, next)