MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / addMiddleware

Function addMiddleware

packages/hono/src/index.ts:28–48  ·  view source on GitHub ↗
(
  app: Hono<TEnv>,
  callback: (env: TEnv["Bindings"]) => TriggerClient
)

Source from the content-addressed store, hash-verified

26}
27
28export function addMiddleware<TEnv extends Env>(
29 app: Hono<TEnv>,
30 callback: (env: TEnv["Bindings"]) => TriggerClient
31) {
32 app.use("/api/trigger", async (c, next) => {
33 const client = callback(c.env);
34
35 if (c.req.method === "HEAD") {
36 return new Response(null, { status: 200 });
37 }
38
39 const request = convertToStandardRequest(c.req);
40
41 const response = await client.handleRequest(request);
42
43 return new Response(JSON.stringify(response.body), {
44 status: response.status,
45 headers: response.headers,
46 });
47 });
48}
49
50function convertToStandardRequest(req: HonoRequest): Request {
51 const headers: Record<string, string> = {};

Callers 1

index.tsFile · 0.90

Calls 3

useMethod · 0.80
convertToStandardRequestFunction · 0.70
handleRequestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…