UNPKG

hono

Version:

Web framework built on Web Standards

40 lines (39 loc) 901 B
/** * @module * Context Storage Middleware for Hono. */ import type { Context } from '../../context'; import type { Env, MiddlewareHandler } from '../../types'; /** * Context Storage Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/context-storage} * * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * type Env = { * Variables: { * message: string * } * } * * const app = new Hono<Env>() * * app.use(contextStorage()) * * app.use(async (c, next) => { * c.set('message', 'Hono is cool!!) * await next() * }) * * app.get('/', async (c) => { c.text(getMessage()) }) * * const getMessage = () => { * return getContext<Env>().var.message * } * ``` */ export declare const contextStorage: () => MiddlewareHandler; export declare const getContext: <E extends Env = Env>() => Context<E, any, {}>;