Skip to content

Commit cc5ecbf

Browse files
committed
handle custom buckets properly in effect
1 parent b698414 commit cc5ecbf

File tree

8 files changed

+248
-148
lines changed

8 files changed

+248
-148
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Api extends HttpApi.make("CapWebApi").add(
4141
.addError(HttpApiError.InternalServerError)
4242
.addError(HttpApiError.NotFound),
4343
),
44-
) {}
44+
) { }
4545

4646
const ApiLive = HttpApiBuilder.api(Api).pipe(
4747
Layer.provide(
@@ -76,6 +76,7 @@ const ApiLive = HttpApiBuilder.api(Api).pipe(
7676
PolicyDenied: () => new HttpApiError.Unauthorized(),
7777
DatabaseError: () => new HttpApiError.InternalServerError(),
7878
S3Error: () => new HttpApiError.InternalServerError(),
79+
UnknownException: () => new HttpApiError.InternalServerError(),
7980
}),
8081
),
8182
);
@@ -128,6 +129,8 @@ const getPlaylistResponse = (
128129
);
129130
}
130131

132+
yield* Effect.log("Resolving path with custom bucket");
133+
131134
const videoPrefix = `${video.ownerId}/${video.id}/video/`;
132135
const audioPrefix = `${video.ownerId}/${video.id}/audio/`;
133136

@@ -155,6 +158,9 @@ const getPlaylistResponse = (
155158
headers: CACHE_CONTROL_HEADERS,
156159
});
157160
} else if (video.source.type === "desktopMP4") {
161+
yield* Effect.log(
162+
`Returning path ${`${video.ownerId}/${video.id}/result.mp4`}`,
163+
);
158164
return yield* s3
159165
.getSignedObjectUrl(`${video.ownerId}/${video.id}/result.mp4`)
160166
.pipe(Effect.map(HttpServerResponse.redirect));
@@ -192,13 +198,11 @@ const getPlaylistResponse = (
192198
const generatedPlaylist = generateMasterPlaylist(
193199
videoMetadata?.Metadata?.resolution ?? "",
194200
videoMetadata?.Metadata?.bandwidth ?? "",
195-
`${serverEnv().WEB_URL}/api/playlist?userId=${
196-
video.ownerId
201+
`${serverEnv().WEB_URL}/api/playlist?userId=${video.ownerId
197202
}&videoId=${video.id}&videoType=video`,
198203
audioMetadata
199-
? `${serverEnv().WEB_URL}/api/playlist?userId=${
200-
video.ownerId
201-
}&videoId=${video.id}&videoType=audio`
204+
? `${serverEnv().WEB_URL}/api/playlist?userId=${video.ownerId
205+
}&videoId=${video.id}&videoType=audio`
202206
: null,
203207
);
204208

apps/web/app/api/video/delete/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Api extends HttpApi.make("Api").add(
1919
.addError(HttpApiError.Forbidden)
2020
.addError(HttpApiError.NotFound),
2121
),
22-
) {}
22+
) { }
2323

2424
const ApiLive = HttpApiBuilder.api(Api).pipe(
2525
Layer.provide(
@@ -40,6 +40,10 @@ const ApiLive = HttpApiBuilder.api(Api).pipe(
4040
Effect.logError(e).pipe(
4141
Effect.andThen(() => new HttpApiError.InternalServerError()),
4242
),
43+
UnknownException: (e) =>
44+
Effect.logError(e).pipe(
45+
Effect.andThen(() => new HttpApiError.InternalServerError()),
46+
),
4347
}),
4448
),
4549
);

packages/database/crypto.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TODO: port this all to Effect
2+
13
import { timingSafeEqual } from "node:crypto";
24
import { serverEnv } from "@cap/env";
35

0 commit comments

Comments
 (0)