Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Transcribe status route

Richie McIlroyd63b2d3dbf65
diff --git a/apps/web/app/api/video/transcribe/status/route.ts b/apps/web/app/api/video/transcribe/status/route.ts
new file mode 100644
index 000000000..bb101e192
--- /dev/null
+++ b/apps/web/app/api/video/transcribe/status/route.ts
@@ -0,0 +1,59 @@
+import { isUserOnProPlan } from "@cap/utils";
+import { getCurrentUser } from "@cap/database/auth/session";
+import { NextRequest } from "next/server";
+import { count, eq } from "drizzle-orm";
+import { db } from "@cap/database";
+import { videos } from "@cap/database/schema";
+
+export async function GET(request: NextRequest) {
+ const user = await getCurrentUser();
+ const url = new URL(request.url);
+ const videoId = url.searchParams.get("videoId");
+
+ if (!user) {
+ return new Response(JSON.stringify({ auth: false }), {
+ status: 401,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ });
+ }
+
+ if (!videoId) {
+ return new Response(
+ JSON.stringify({ error: true, message: "videoId not supplied" }),
+ {
+ status: 400,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+ }
+
+ const video = await db.select().from(videos).where(eq(videos.id, videoId));
+
+ if (video.length === 0) {
+ return new Response(
+ JSON.stringify({ error: true, message: "Video does not exist" }),
+ {
+ status: 404,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+ }
+
+ return new Response(
+ JSON.stringify({
+ transcriptionStatus: video[0].transcriptionStatus,
+ }),
+ {
+ status: 200,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+}