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

Function action

apps/webapp/app/routes/api.v1.deployments.ts:8–49  ·  view source on GitHub ↗
({ request, params }: ActionFunctionArgs)

Source from the content-addressed store, hash-verified

6import { InitializeDeploymentService } from "~/v3/services/initializeDeployment.server";
7
8export async function action({ request, params }: ActionFunctionArgs) {
9 // Ensure this is a POST request
10 if (request.method.toUpperCase() !== "POST") {
11 return { status: 405, body: "Method Not Allowed" };
12 }
13
14 // Next authenticate the request
15 const authenticationResult = await authenticateApiRequest(request);
16
17 if (!authenticationResult) {
18 logger.info("Invalid or missing api key", { url: request.url });
19 return json({ error: "Invalid or Missing API key" }, { status: 401 });
20 }
21
22 const rawBody = await request.json();
23 const body = InitializeDeploymentRequestBody.safeParse(rawBody);
24
25 if (!body.success) {
26 return json({ error: "Invalid body", issues: body.error.issues }, { status: 400 });
27 }
28
29 const authenticatedEnv = authenticationResult.environment;
30
31 const service = new InitializeDeploymentService();
32
33 const { deployment, imageTag } = await service.call(authenticatedEnv, body.data);
34
35 const responseBody: InitializeDeploymentResponseBody = {
36 id: deployment.friendlyId,
37 contentHash: deployment.contentHash,
38 shortCode: deployment.shortCode,
39 version: deployment.version,
40 externalBuildData: deployment.externalBuildData as InitializeDeploymentResponseBody["externalBuildData"],
41 imageTag,
42 registryHost: env.DEPLOY_REGISTRY_HOST
43 }
44
45 return json(
46 responseBody,
47 { status: 200 }
48 );
49}

Callers

nothing calls this directly

Calls 5

callMethod · 0.95
authenticateApiRequestFunction · 0.90
jsonFunction · 0.85
jsonMethod · 0.80
infoMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…