(options: {
path: string,
apiRoutePath: string,
template: string,
fileExtension: string,
endpointSlug: string,
pathAlias: string | undefined
})
| 190 | } |
| 191 | |
| 192 | async 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 | |
| 226 | async function createJobsAndTriggerFile( |
| 227 | path: string, |
no test coverage detected
searching dependent graphs…