Skip to content

Commit 977f023

Browse files
committed
Apply some good 🐰 suggestions
1 parent 31a6644 commit 977f023

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

apps/webapp/app/routes/api.v1.deployments.$deploymentId.start.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,29 @@ export async function action({ request, params }: ActionFunctionArgs) {
4343

4444
const deploymentService = new DeploymentService();
4545

46-
const result = await deploymentService.startDeployment(authenticatedEnv, deploymentId, body.data);
47-
return result.match(
48-
() => {
49-
return json(null, { status: 204 });
50-
},
51-
(error) => {
52-
switch (error.type) {
53-
case "failed_to_extend_deployment_timeout":
54-
return json(null, { status: 204 }); // ignore these errors for now
55-
case "deployment_not_found":
56-
return json({ error: "Deployment not found" }, { status: 404 });
57-
case "deployment_not_pending":
58-
return json({ error: "Deployment is not pending" }, { status: 409 });
59-
case "other":
60-
default:
61-
error.type satisfies "other";
62-
return json({ error: "Internal server error" }, { status: 500 });
46+
await deploymentService
47+
.startDeployment(authenticatedEnv, deploymentId, {
48+
contentHash: body.data.contentHash,
49+
git: body.data.gitMeta,
50+
runtime: body.data.runtime,
51+
})
52+
.match(
53+
() => {
54+
return json(null, { status: 204 });
55+
},
56+
(error) => {
57+
switch (error.type) {
58+
case "failed_to_extend_deployment_timeout":
59+
return json(null, { status: 204 }); // ignore these errors for now
60+
case "deployment_not_found":
61+
return json({ error: "Deployment not found" }, { status: 404 });
62+
case "deployment_not_pending":
63+
return json({ error: "Deployment is not pending" }, { status: 409 });
64+
case "other":
65+
default:
66+
error.type satisfies "other";
67+
return json({ error: "Internal server error" }, { status: 500 });
68+
}
6369
}
64-
}
65-
);
70+
);
6671
}

apps/webapp/app/v3/services/deployment.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { TimeoutDeploymentService } from "./timeoutDeployment.server";
77
import { env } from "~/env.server";
88

99
export class DeploymentService extends BaseService {
10-
public async startDeployment(
10+
public startDeployment(
1111
authenticatedEnv: AuthenticatedEnvironment,
1212
friendlyId: string,
1313
updates: Partial<Pick<WorkerDeployment, "contentHash" | "runtime"> & { git: GitMeta }>
@@ -75,7 +75,7 @@ export class DeploymentService extends BaseService {
7575
type: "failed_to_extend_deployment_timeout" as const,
7676
cause: error,
7777
})
78-
);
78+
).map(() => undefined);
7979

8080
return getDeployment()
8181
.andThen(validateDeployment)

apps/webapp/app/v3/services/initializeDeployment.server.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,14 @@ export class InitializeDeploymentService extends BaseService {
135135
},
136136
});
137137

138+
const timeoutMs =
139+
deployment.status === "PENDING" ? env.DEPLOY_QUEUE_TIMEOUT_MS : env.DEPLOY_TIMEOUT_MS;
140+
138141
await TimeoutDeploymentService.enqueue(
139142
deployment.id,
140143
deployment.status,
141144
"Building timed out",
142-
new Date(
143-
Date.now() + deployment.status === "PENDING"
144-
? env.DEPLOY_QUEUE_TIMEOUT_MS
145-
: env.DEPLOY_TIMEOUT_MS
146-
)
145+
new Date(Date.now() + timeoutMs)
147146
);
148147

149148
return {

0 commit comments

Comments
 (0)