From b8d114606910bb3c9c3937a0ef8096ba649067bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Charles?= Date: Wed, 4 Dec 2024 13:36:00 +0100 Subject: [PATCH] doc: add runtime param to all recipes --- examples/tool/src/middlewares/context.middleware.ts | 2 +- examples/tool/src/middlewares/guard.middleware.ts | 2 +- examples/tool/src/middlewares/headers.middleware.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/tool/src/middlewares/context.middleware.ts b/examples/tool/src/middlewares/context.middleware.ts index 00fb5ec..89f92d3 100644 --- a/examples/tool/src/middlewares/context.middleware.ts +++ b/examples/tool/src/middlewares/context.middleware.ts @@ -3,7 +3,7 @@ import type { Get, UniversalMiddleware } from "@universal-middleware/core"; -const contextMiddleware = ((value) => (request, ctx) => { +const contextMiddleware = ((value) => (request, ctx, runtime) => { // Return the new universal context, thus keeping complete type safety // A less typesafe way to do the same thing would be to `ctx.something = value` and return nothing return { diff --git a/examples/tool/src/middlewares/guard.middleware.ts b/examples/tool/src/middlewares/guard.middleware.ts index 18e9420..b2fdb08 100644 --- a/examples/tool/src/middlewares/guard.middleware.ts +++ b/examples/tool/src/middlewares/guard.middleware.ts @@ -9,7 +9,7 @@ interface User { } // This middleware will return an early Response for unauthenticated users -const guardMiddleware = (() => (request, ctx) => { +const guardMiddleware = (() => (request, ctx, runtime) => { if (!ctx?.user) { return new Response("Unauthorized", { status: 401, diff --git a/examples/tool/src/middlewares/headers.middleware.ts b/examples/tool/src/middlewares/headers.middleware.ts index 33370ea..a9ac53e 100644 --- a/examples/tool/src/middlewares/headers.middleware.ts +++ b/examples/tool/src/middlewares/headers.middleware.ts @@ -4,7 +4,7 @@ import type { Get, UniversalMiddleware } from "@universal-middleware/core"; // This middleware will add a `X-Universal-Hello` header to all responses -const headersMiddleware = (() => (request, ctx) => { +const headersMiddleware = (() => (request, ctx, runtime) => { return (response) => { // `ctx.hello` exists if it has been set by another middleware response.headers.set("X-Universal-Hello", ctx.hello ?? "world");