Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

ServerMiddleware

tipo

Middleware de servidor: envuelve las peticiones HTTP de páginas, API y RPC antes de que Meeko cree su contexto. Recibe la petición y next(request?), que sólo se puede llamar una vez, y devuelve un Response.

ts
import type { ServerMiddleware } from "@meekojs/meeko/server";

Source code src/server/middleware/index.ts:21

Declaración #

ts
type ServerMiddleware = (request: Request, next: (request?: Request) => Promise<Response>) => Response | Promise<Response>

Example #

ts
import type { ServerMiddleware } from "@meekojs/meeko/server";

const timing: ServerMiddleware = async (request, next) => {
  const start = performance.now();
  const response = await next();
  console.log(request.method, new URL(request.url).pathname, Math.round(performance.now() - start), "ms");
  return response;
};

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/server/middleware/index.ts