Files
SnowLuma/.pnpm-store/v11/files/f2/acca12bebb19591b42347aca98c575a6aabce79ee9f9db7a27e1861bcb55662973c02b8613a714d7c96218288e0d31f2f9e72f76d54f8f6f6dc5fe59a3c0d9
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

38 lines
976 B
Plaintext

import { Env, MiddlewareHandler } from "../../types.js";
import { Context } from "../../context.js";
//#region src/middleware/context-storage/index.d.ts
/**
* 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 hot!!')
* await next()
* })
*
* app.get('/', async (c) => c.text(getMessage()))
*
* const getMessage = () => {
* return getContext<Env>().var.message
* }
* ```
*/
export declare const contextStorage: () => MiddlewareHandler;
export declare const tryGetContext: <E extends Env = Env>() => Context<E> | undefined;
export declare const getContext: <E extends Env = Env>() => Context<E>;
//#endregion