Skip to content

Commit 0a56270

Browse files
committed
fix(api): fix project deletion
1 parent 894a135 commit 0a56270

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

apps/api/src/api/projects/index.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
listProjects,
77
getProjectById,
88
updateProject,
9-
deleteProject,
9+
deleteProjectCascade,
1010
listDomains,
1111
} from "../../db/repo";
1212
import { tryRun, reloadCaddy } from "../../orchestrator/runtime";
@@ -79,7 +79,6 @@ export const projectsRoutes = new Elysia()
7979
return { error: "Project not found" };
8080
}
8181

82-
// Docker containers cleanup
8382
for (const name of info.deploymentContainerNames) {
8483
await tryRun(dockerBin, ['stop', '-t', '5', name]);
8584
await tryRun(dockerBin, ['rm', '-f', name]);
@@ -89,22 +88,18 @@ export const projectsRoutes = new Elysia()
8988
await tryRun(dockerBin, ['rm', '-f', name]);
9089
}
9190

92-
// Docker volumes cleanup
9391
for (const name of [...info.databaseVolumeNames, ...info.volumeDockerNames]) {
9492
await tryRun(dockerBin, ['volume', 'rm', '-f', name]);
9593
}
9694

97-
// Docker images cleanup
9895
for (const tag of info.deploymentImageTags) {
9996
if (tag) await tryRun(dockerBin, ['rmi', '-f', tag]);
10097
}
10198

102-
// Remove domains from Caddy route file
10399
for (const { domain, projectName } of info.domains) {
104100
await removeFromCaddyRoute(domain, id, projectName);
105101
}
106102

107-
// Delete the Caddy route file for this project's slug
108103
const caddyFilePath = join(config.caddyRoutesDir, `${info.slug}.caddy`);
109104
await unlink(caddyFilePath).catch(() => {});
110105
await reloadCaddy().catch(() => {});
@@ -206,14 +201,14 @@ export const projectsRoutes = new Elysia()
206201
}
207202

208203
const regexEscaped = domains.map(d => d.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\\\$&')).join('|');
209-
204+
210205
// Loki metric query for request rate
211206
const query = `sum(count_over_time({container="dequel-caddy-1"} | json | request_host =~ "^(${regexEscaped})$" [5m]))`;
212-
207+
213208
const end = Math.floor(Date.now() / 1000);
214209
const start = end - (6 * 60 * 60); // 6 hours ago
215210
const step = "60s"; // 1 min resolution
216-
211+
217212
try {
218213
const response = await fetch(
219214
`http://loki:3100/loki/api/v1/query_range?query=${encodeURIComponent(query)}&start=${start}&end=${end}&step=${step}`
@@ -304,8 +299,8 @@ export const projectsRoutes = new Elysia()
304299
ws.onmessage = (event) => {
305300
if (closed) return;
306301
try {
307-
const dataStr = typeof event.data === "string"
308-
? event.data
302+
const dataStr = typeof event.data === "string"
303+
? event.data
309304
: new TextDecoder().decode(event.data as any);
310305
const data = JSON.parse(dataStr) as any;
311306
if (data.streams) {

0 commit comments

Comments
 (0)