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

Function createTriggerRoute

packages/cli/src/frameworks/nextjs/index.ts:192–224  ·  view source on GitHub ↗
(options: {
  path: string,
  apiRoutePath: string,
  template: string,
  fileExtension: string,
  endpointSlug: string,
  pathAlias: string | undefined
})

Source from the content-addressed store, hash-verified

190}
191
192async function createTriggerRoute(options: {
193 path: string,
194 apiRoutePath: string,
195 template: string,
196 fileExtension: string,
197 endpointSlug: string,
198 pathAlias: string | undefined
199}) {
200 const { path, apiRoutePath, template, pathAlias, endpointSlug, fileExtension } = options;
201
202 const templatesDir = pathModule.join(templatesPath(), "nextjs");
203 const apiRouteResult = await createFileFromTemplate({
204 templatePath: pathModule.join(templatesDir, template),
205 replacements: {
206 routePathPrefix: pathAlias ? pathAlias + "/" : "../../",
207 },
208 outputPath: apiRoutePath,
209 });
210 if (!apiRouteResult.success) {
211 throw new Error("Failed to create API route file");
212 }
213 logger.success(`✔ Created API route at ${apiRoutePath}`);
214 logger.info(
215 boxen(`If you're deploying to Vercel, configure your max duration in ${apiRoutePath}`, {
216 padding: 1,
217 margin: 1,
218 borderStyle: "double",
219 borderColor: "magenta",
220 })
221 );
222
223 await createJobsAndTriggerFile(path, endpointSlug, fileExtension, pathAlias, templatesDir);
224}
225
226async function createJobsAndTriggerFile(
227 path: string,

Callers 1

installMethod · 0.85

Calls 4

templatesPathFunction · 0.90
createFileFromTemplateFunction · 0.90
createJobsAndTriggerFileFunction · 0.85
infoMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…