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

Function handler

packages/nextjs/src/index.ts:5–25  ·  view source on GitHub ↗
(req: NextApiRequest, res: NextApiResponse)

Source from the content-addressed store, hash-verified

3
4export function createPagesRoute(client: TriggerClient) {
5 const handler = async function handler(req: NextApiRequest, res: NextApiResponse) {
6 const normalizedRequest = await convertToStandardRequest(req);
7
8 const response = await client.handleRequest(normalizedRequest);
9
10 if (!response) {
11 res.status(404).json({ error: "Not found" });
12
13 return;
14 }
15
16 if (response.headers) {
17 for (const [key, value] of Object.entries(response.headers)) {
18 if (typeof value === "string") {
19 res.setHeader(key, value);
20 }
21 }
22 }
23
24 res.status(response.status).json(response.body);
25 };
26
27 return {
28 handler,

Callers 4

handleMessageMethod · 0.50
handleMessageMethod · 0.50
handleMessageMethod · 0.50

Calls 3

jsonMethod · 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…