MCPcopy
hub / github.com/triggerdotdev/trigger.dev / createMiddleware

Function createMiddleware

packages/hono/src/index.ts:4–26  ·  view source on GitHub ↗
(
  client: TriggerClient,
  path: string = "/api/trigger"
)

Source from the content-addressed store, hash-verified

2import type { Env, Hono, HonoRequest, MiddlewareHandler } from "hono";
3
4export function createMiddleware(
5 client: TriggerClient,
6 path: string = "/api/trigger"
7): MiddlewareHandler {
8 return async (c, next) => {
9 if (c.req.path !== path) {
10 return await next();
11 }
12
13 if (c.req.method === "HEAD") {
14 return new Response(null, { status: 200 });
15 }
16
17 const request = convertToStandardRequest(c.req);
18
19 const response = await client.handleRequest(request);
20
21 return new Response(JSON.stringify(response.body), {
22 status: response.status,
23 headers: response.headers,
24 });
25 };
26}
27
28export function addMiddleware<TEnv extends Env>(
29 app: Hono<TEnv>,

Callers 4

createAppFunction · 0.90
createAppFunction · 0.90
index.tsFile · 0.90
createAppFunction · 0.50

Calls 2

convertToStandardRequestFunction · 0.70
handleRequestMethod · 0.45

Tested by 3

createAppFunction · 0.72
createAppFunction · 0.72
createAppFunction · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…