Skip to content

Commit cd8e32f

Browse files
committed
remove revalidate + trace drizzle properly
1 parent be66a20 commit cd8e32f

10 files changed

Lines changed: 68 additions & 177 deletions

File tree

apps/web/actions/video/upload.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,6 @@ async function getVideoUploadPresignedUrl({
131131
return presignedPostData;
132132
}).pipe(runPromise);
133133

134-
const videoId = fileKey.split("/")[1];
135-
if (videoId) {
136-
try {
137-
await fetch(`${serverEnv().WEB_URL}/api/revalidate`, {
138-
method: "POST",
139-
headers: {
140-
"Content-Type": "application/json",
141-
},
142-
body: JSON.stringify({ videoId }),
143-
});
144-
} catch (revalidateError) {
145-
console.error("Failed to revalidate page:", revalidateError);
146-
}
147-
}
148-
149134
return { presignedPostData };
150135
} catch (error) {
151136
console.error("Error getting presigned URL:", error);

apps/web/app/api/revalidate/route.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

apps/web/app/api/upload/[...route]/multipart.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -322,23 +322,6 @@ app.post(
322322
.where(eq(videoUploads.videoId, Video.VideoId.make(videoId)));
323323
}
324324

325-
if (videoIdFromFileKey) {
326-
try {
327-
await fetch(`${serverEnv().WEB_URL}/api/revalidate`, {
328-
method: "POST",
329-
headers: {
330-
"Content-Type": "application/json",
331-
},
332-
body: JSON.stringify({ videoId: videoIdFromFileKey }),
333-
});
334-
console.log(
335-
`Revalidation triggered for videoId: ${videoIdFromFileKey}`,
336-
);
337-
} catch (revalidateError) {
338-
console.error("Failed to revalidate page:", revalidateError);
339-
}
340-
}
341-
342325
return c.json({
343326
location: result.Location,
344327
success: true,

apps/web/app/api/upload/[...route]/signed.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,6 @@ app.post(
172172
),
173173
);
174174

175-
if (videoIdFromKey) {
176-
try {
177-
await fetch(`${serverEnv().WEB_URL}/api/revalidate`, {
178-
method: "POST",
179-
headers: {
180-
"Content-Type": "application/json",
181-
},
182-
body: JSON.stringify({ videoId: videoIdFromKey }),
183-
});
184-
} catch (revalidateError) {
185-
console.error("Failed to revalidate page:", revalidateError);
186-
}
187-
}
188-
189175
if (method === "post") return c.json({ presignedPostData: data! });
190176
else return c.json({ presignedPutData: data! });
191177
} catch (s3Error) {

apps/web/instrumentation.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { OTLPHttpJsonTraceExporter, registerOTel } from "@vercel/otel";
22

33
export async function register() {
44
if (process.env.NEXT_PUBLIC_AXIOM_TOKEN) {
5-
console.log("token", process.env.NEXT_PUBLIC_AXIOM_TOKEN);
6-
console.log("dataset", process.env.NEXT_PUBLIC_AXIOM_DATASET);
75
registerOTel({
86
serviceName: "cap-web-backend",
97
traceExporter: new OTLPHttpJsonTraceExporter({
@@ -14,6 +12,11 @@ export async function register() {
1412
},
1513
}),
1614
});
15+
} else if (process.env.NODE_ENV === "development") {
16+
registerOTel({
17+
serviceName: "cap-web-backend",
18+
traceExporter: new OTLPHttpJsonTraceExporter({}),
19+
});
1720
}
1821

1922
if (process.env.NEXT_RUNTIME === "nodejs") {

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@hono/zod-validator": "^0.4.3",
4242
"@hookform/resolvers": "^3.3.2",
4343
"@intercom/messenger-js-sdk": "^0.0.14",
44+
"@kubiks/otel-drizzle": "^2.1.0",
4445
"@mux/mux-node": "^8.5.1",
4546
"@mux/mux-player-react": "^3.3.0",
4647
"@number-flow/react": "^0.5.9",

packages/database/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { instrumentDrizzleClient } from "@kubiks/otel-drizzle";
12
import { Client, type Config } from "@planetscale/database";
23
import { sql } from "drizzle-orm";
34
import type { AnyMySqlColumn } from "drizzle-orm/mysql-core";
@@ -29,6 +30,8 @@ let _cached: ReturnType<typeof createDrizzle> | undefined;
2930
export const db = () => {
3031
if (!_cached) {
3132
_cached = createDrizzle();
33+
34+
instrumentDrizzleClient(_cached);
3235
}
3336
return _cached;
3437
};

packages/database/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@cap/env": "workspace:*",
2020
"@cap/web-domain": "workspace:*",
2121
"@effect/sql-mysql2": "^0.47.0",
22+
"@kubiks/otel-drizzle": "^2.1.0",
2223
"@mattrax/mysql-planetscale": "^0.0.3",
2324
"@paralleldrive/cuid2": "^2.2.2",
2425
"@planetscale/database": "^1.13.0",

packages/web-backend/src/Database.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ export class Database extends Effect.Service<Database>()("Database", {
88
return {
99
use: <T>(
1010
cb: (_: ReturnType<typeof db>) => Promise<T> & { toSQL?(): Query },
11-
) => {
12-
const promise = cb(db());
13-
const sql = promise.toSQL?.().sql ?? "Transaction";
14-
15-
return Effect.tryPromise({
16-
try: () => promise,
11+
) =>
12+
Effect.tryPromise({
13+
try: () => cb(db()),
1714
catch: (cause) => new DatabaseError({ cause }),
18-
}).pipe(Effect.withSpan("Database.execute", { attributes: { sql } }));
19-
},
15+
}),
2016
};
2117
}),
2218
}) {}

0 commit comments

Comments
 (0)