Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Auth.js implementation

Richie McIlroy3091b976c5ac
diff --git a/.env.example b/.env.example
index 76528cb8b..03e9a8909 100644
--- a/.env.example
+++ b/.env.example
@@ -17,8 +17,6 @@
NEXT_PUBLIC_ENVIRONMENT=development
NEXT_PUBLIC_URL=http://localhost:3000
-# For use with linking to web app
-VITE_PUBLIC_URL=http://localhost:3000
# -- database ****************
DB_MYSQL_MIGRATION_URL="mysql://root:@localhost:3306/planetscale"
@@ -35,9 +33,8 @@ NEXTAUTH_SECRET=
## Uses CAP_ prefix to avoid conflict with env variables set in hosting environment. (e.g. Vercel)
CAP_AWS_ACCESS_KEY=
CAP_AWS_SECRET_KEY=
+CAP_AWS_BUCKET=
CAP_AWS_REGION=
-VITE_AWS_BUCKET=
-VITE_AWS_REGION=
# -- resend ****************
## For use with email authentication (sign up, sign in, forgot password)
diff --git a/apps/desktop/src/app/options/page.tsx b/apps/desktop/src/app/options/page.tsx
index 7f1d750c4..60d064d14 100644
--- a/apps/desktop/src/app/options/page.tsx
+++ b/apps/desktop/src/app/options/page.tsx
@@ -1,10 +1,28 @@
"use client";
+import React, { useState, useEffect } from "react";
+import { getCookie } from "cookies-next";
import { SignIn } from "@/components/windows/inner/SignIn";
import { Recorder } from "@/components/windows/inner/Recorder";
import { WindowActions } from "@/components/WindowActions";
export default function CameraPage() {
+ const [isSignedIn, setIsSignedIn] = useState(false);
+
+ useEffect(() => {
+ const cookie = getCookie("next-auth.session-token");
+ setIsSignedIn(!!cookie);
+ }, []);
+
+ useEffect(() => {
+ const interval = setInterval(() => {
+ const cookie = getCookie("next-auth.session-token");
+ setIsSignedIn(!!cookie);
+ }, 1000);
+
+ return () => clearInterval(interval);
+ }, []);
+
return (
<div
id="app"
@@ -13,7 +31,7 @@ export default function CameraPage() {
className="pt-4"
>
<WindowActions />
- <SignIn />
+ {isSignedIn ? <Recorder /> : <SignIn />}
</div>
);
}
diff --git a/apps/desktop/src/app/styles.css b/apps/desktop/src/app/styles.css
index 7ff047052..bf625914e 100644
--- a/apps/desktop/src/app/styles.css
+++ b/apps/desktop/src/app/styles.css
@@ -162,7 +162,7 @@ body {
}
#app {
- @apply bg-gradient-to-b from-[rgba(255,255,255,0.9)] to-[rgba(255,255,255,0.4)];
+ @apply bg-gradient-to-b from-[rgba(255,255,255,0.9)] to-[rgba(255,255,255,0.1)];
}
* {
diff --git a/apps/desktop/src/components/recording/ActionButton.tsx b/apps/desktop/src/components/recording/ActionButton.tsx
index 8c6eab166..9aeb0fefd 100644
--- a/apps/desktop/src/components/recording/ActionButton.tsx
+++ b/apps/desktop/src/components/recording/ActionButton.tsx
@@ -18,8 +18,10 @@ export const ActionButton = ({
<button
onClick={handler}
className={`${
- active === true ? "bg-white" : "bg-gray-200"
- } border-gray-300 hover:bg-white w-full h-[50px] py-2 px-4 text-[15px] border-2 flex items-center justify-start rounded-[15px] flex-grow transition-all`}
+ active === true
+ ? "bg-white hover:bg-gray-100"
+ : "bg-gray-100 hover:bg-white"
+ } border-gray-300 w-full h-[50px] py-2 px-4 text-[15px] border-2 flex items-center justify-start rounded-[15px] flex-grow transition-all shadow-sm shadow-[0px 0px 180px rgba(255, 255, 255, 0.18)]`}
>
<span>{icon}</span>
{label && (
diff --git a/apps/desktop/src/components/windows/inner/Countdown.tsx b/apps/desktop/src/components/windows/inner/Countdown.tsx
index 7d60ff50f..fccc7601d 100644
--- a/apps/desktop/src/components/windows/inner/Countdown.tsx
+++ b/apps/desktop/src/components/windows/inner/Countdown.tsx
@@ -25,7 +25,7 @@ export const Countdown: React.FC<CountdownOverlayProps> = ({
return () => clearTimeout(timerId);
}, [countdown, onCountdownFinish]);
- return countdown > 0 ? (
+ return (
<div
className="absolute inset-0 z-50 flex items-center justify-center"
style={{
@@ -34,5 +34,5 @@ export const Countdown: React.FC<CountdownOverlayProps> = ({
>
<span className="text-white text-6xl font-bold">{countdown}</span>
</div>
- ) : null;
+ );
};
diff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsx
index bf7a09e09..c9e35fdf6 100644
--- a/apps/desktop/src/components/windows/inner/Recorder.tsx
+++ b/apps/desktop/src/components/windows/inner/Recorder.tsx
@@ -14,11 +14,6 @@ import { showMenu } from "tauri-plugin-context-menu";
import { invoke } from "@tauri-apps/api/tauri";
import { Countdown } from "./Countdown";
import callbackTemplate from "./callbackTemplate";
-// import { AuthSession } from "@supabase/supabase-js";
-// import { supabase } from "@/utils/database/client";
-// import type { Database } from "@cap/utils";
-
-//TODO: Auth
import { useMediaRecorder } from "@/utils/recording/useMediaRecorder";
import { getSelectedVideoProperties } from "@/utils/recording/utils";
@@ -78,55 +73,57 @@ export const Recorder = () => {
};
const handleOverlayFinished = () => {
- appWindow.setSize(new LogicalSize(0, 0));
- WebviewWindow.getByLabel("camera")?.setSize(new LogicalSize(0, 0));
+ // appWindow.hide();
+ // WebviewWindow.getByLabel("camera")?.hide();
setIsRecording(true);
setCountdownActive(false);
};
- // const prepareVideoData = async () => {
- // return await supabase
- // .from("videos")
- // .insert({
- // owner_id: session?.user?.id,
- // aws_region: import.meta.env.VITE_AWS_REGION,
- // aws_bucket: import.meta.env.VITE_AWS_BUCKET,
- // })
- // .select()
- // .single()
- // .then(
- // ({
- // data,
- // error,
- // }: {
- // data: Database["public"]["Tables"]["videos"]["Row"] | null;
- // error: any;
- // }) => {
- // if (error) {
- // console.error("Error fetching video data:", error);
- // return null;
- // }
- // if (!data) {
- // console.error("No video data received");
- // return null;
- // }
- // saveLatestVideoId(data.id);
- // return data;
- // }
- // );
- // };
+ const prepareVideoData = async () => {
+ const res = await fetch(
+ `${process.env.NEXT_PUBLIC_URL}/api/desktop/video/create`,
+ {
+ credentials: "include",
+ }
+ );
+
+ if (res.status === 401) {
+ console.error("Unauthorized");
+ toast.error("Unauthorized - please sign in again.");
+ return;
+ }
+
+ const data = await res.json();
+
+ console.log("data:");
+ console.log(data);
+
+ if (!data.id || !data.user_id || !data.aws_region || !data.aws_bucket) {
+ console.error("No data received");
+ toast.error("No data received - please try again later.");
+ return;
+ }
+
+ saveLatestVideoId(data.id);
+
+ return data;
+ };
const startDualRecording = async (videoData: {
- id: any;
- aws_region: any;
- aws_bucket: any;
+ id: string;
+ user_id: string;
+ aws_region: string;
+ aws_bucket: string;
}) => {
// Extracted from the useEffect hook; this starts the video recording
+ console.log("Starting dual recording...");
+ console.log("video data:");
+ console.log(videoData);
const mediaSettings = await getSelectedVideoProperties();
if (mediaSettings?.resolution && mediaSettings?.framerate) {
await invoke("start_dual_recording", {
options: {
- // user_id: session?.user?.id,
+ user_id: videoData.user_id,
video_id: videoData.id,
aws_region: videoData.aws_region,
aws_bucket: videoData.aws_bucket,
@@ -145,22 +142,24 @@ export const Recorder = () => {
const handleStartAllRecordings = async () => {
setCountdownActive(true);
- // try {
- // const videoData = await prepareVideoData();
- // if (videoData) {
- // const stream = await navigator.mediaDevices.getUserMedia({
- // audio: { deviceId: selectedAudioDevice?.deviceId },
- // video: { deviceId: selectedVideoDevice?.deviceId },
- // });
- // await startMediaRecording(stream);
- // await startDualRecording(videoData);
- // } else {
- // throw new Error("Failed to prepare video data.");
- // }
- // } catch (error) {
- // console.error("Error starting recordings:", error);
- // setCountdownActive(false);
- // }
+ try {
+ const videoData = await prepareVideoData();
+ console.log("videoData:");
+ console.log(videoData);
+ if (videoData) {
+ const stream = await navigator.mediaDevices.getUserMedia({
+ audio: { deviceId: selectedAudioDevice?.deviceId },
+ video: { deviceId: selectedVideoDevice?.deviceId },
+ });
+ await startMediaRecording(stream);
+ await startDualRecording(videoData);
+ } else {
+ throw new Error("Failed to prepare video data.");
+ }
+ } catch (error) {
+ console.error("Error starting recordings:", error);
+ setCountdownActive(false);
+ }
};
const handleStopAllRecordings = async () => {
@@ -178,9 +177,7 @@ export const Recorder = () => {
console.log("Opening window...");
await openLinkInBrowser(
- `${process.env.NEXT_PUBLIC_URL}/share/${uuidParse(
- await getLatestVideoId()
- )}`
+ `${process.env.NEXT_PUBLIC_URL}/share/${await getLatestVideoId()}`
);
setIsRecording(false);
diff --git a/apps/desktop/src/components/windows/inner/SignIn.tsx b/apps/desktop/src/components/windows/inner/SignIn.tsx
index 8a129aebf..a7ddf92f5 100644
--- a/apps/desktop/src/components/windows/inner/SignIn.tsx
+++ b/apps/desktop/src/components/windows/inner/SignIn.tsx
@@ -20,12 +20,12 @@ export const SignIn = () => {
return;
}
- console.log("cookie:");
- console.log(cookie);
-
- const res = await fetch("http://localhost:3000/api/session/verify", {
- credentials: "include",
- });
+ const res = await fetch(
+ `${process.env.NEXT_PUBLIC_URL}/api/desktop/session/verify`,
+ {
+ credentials: "include",
+ }
+ );
const data = await res.json();
console.log("dataaa:");
console.log(data);
diff --git a/apps/desktop/src/utils/auth/index.ts b/apps/desktop/src/utils/auth/index.ts
index 14f3aa1f1..24124fa90 100644
--- a/apps/desktop/src/utils/auth/index.ts
+++ b/apps/desktop/src/utils/auth/index.ts
@@ -6,12 +6,11 @@ import { parse } from "url";
export const openSignIn = async (port: string) => {
await open(
- `http://localhost:3000/api/session/request?redirectUrl=http://localhost:${port}`
+ `${process.env.NEXT_PUBLIC_URL}/api/desktop/session/request?redirectUrl=http://localhost:${port}`
);
};
export const login = () => {
- // Wait for callback from tauri oauth plugin
listen("oauth://url", (data: { payload: string }) => {
if (!data.payload.includes("token")) {
return;
@@ -31,12 +30,8 @@ export const login = () => {
document.cookie = `next-auth.session-token=${token}; expires=${expiresDate.toUTCString()}; path=/`;
});
- // Start tauri oauth plugin. When receive first request
- // When it starts, will return the server port
- // it will kill the server
invoke("plugin:oauth|start", {
config: {
- // Optional config, but use here to more friendly callback page
response: callbackTemplate,
},
}).then((port) => {
diff --git a/apps/desktop/src/utils/database/utils.ts b/apps/desktop/src/utils/database/utils.ts
index c8714fcb4..a40373177 100644
--- a/apps/desktop/src/utils/database/utils.ts
+++ b/apps/desktop/src/utils/database/utils.ts
@@ -1,23 +1,33 @@
export const saveLatestVideoId = async (videoId: string) => {
try {
- window.localStorage.setItem("latestVideoId", videoId);
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
+ window.localStorage.setItem("latestVideoId", videoId);
+ }
} catch (error) {
console.error(error);
}
};
export const getLatestVideoId = async () => {
- return window.localStorage.getItem("latestVideoId") || "";
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
+ return window.localStorage.getItem("latestVideoId") || "";
+ }
+
+ return "";
};
export const saveUserId = async (userId: string) => {
- try {
- window.localStorage.setItem("userId", userId);
- } catch (error) {
- console.error(error);
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
+ try {
+ window.localStorage.setItem("userId", userId);
+ } catch (error) {
+ console.error(error);
+ }
}
};
export const getUserId = async () => {
- return window.localStorage.getItem("userId") || "";
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
+ return window.localStorage.getItem("userId") || "";
+ }
};
diff --git a/apps/desktop/src/utils/recording/useMediaRecorder.ts b/apps/desktop/src/utils/recording/useMediaRecorder.ts
index 73e862222..98d05e25e 100644
--- a/apps/desktop/src/utils/recording/useMediaRecorder.ts
+++ b/apps/desktop/src/utils/recording/useMediaRecorder.ts
@@ -1,5 +1,5 @@
import { useState, useRef, useCallback } from "react";
-import { writeBinaryFile } from "@tauri-apps/api/fs";
+import { writeBinaryFile, createDir } from "@tauri-apps/api/fs";
import { appDataDir, join } from "@tauri-apps/api/path";
import { writeTextFile, readTextFile } from "@tauri-apps/api/fs";
@@ -67,6 +67,7 @@ export const useMediaRecorder = () => {
async (stream: MediaStream) => {
chunkCounter.current = 0;
const dir = await getVideoChunksDir();
+ await createDir(dir, { recursive: true });
const segmentListPath = await join(dir, "segment_list.txt");
await writeTextFile({ path: segmentListPath, contents: "" });
diff --git a/apps/desktop/src/utils/recording/utils.ts b/apps/desktop/src/utils/recording/utils.ts
index 9f1e510e9..b83b1234c 100644
--- a/apps/desktop/src/utils/recording/utils.ts
+++ b/apps/desktop/src/utils/recording/utils.ts
@@ -1,30 +1,40 @@
export const enumerateAndStoreDevices = async () => {
- await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
- const devices = await navigator.mediaDevices.enumerateDevices();
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
+ await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
+ const devices = await navigator.mediaDevices.enumerateDevices();
- const videoDevices = devices.filter((device) => device.kind === "videoinput");
- const audioDevices = devices.filter((device) => device.kind === "audioinput");
+ const videoDevices = devices.filter(
+ (device) => device.kind === "videoinput"
+ );
+ const audioDevices = devices.filter(
+ (device) => device.kind === "audioinput"
+ );
- window.localStorage.setItem("videoDevices", JSON.stringify(videoDevices));
- window.localStorage.setItem("audioDevices", JSON.stringify(audioDevices));
+ window.localStorage.setItem("videoDevices", JSON.stringify(videoDevices));
+ window.localStorage.setItem("audioDevices", JSON.stringify(audioDevices));
+ }
};
export const getLocalDevices = async () => {
- const videoDevices = JSON.parse(
- window.localStorage.getItem("videoDevices") || "[]"
- ) as MediaDeviceInfo[];
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
+ const videoDevices = JSON.parse(
+ window.localStorage.getItem("videoDevices") || "[]"
+ ) as MediaDeviceInfo[];
- const audioDevices = JSON.parse(
- window.localStorage.getItem("audioDevices") || "[]"
- ) as MediaDeviceInfo[];
+ const audioDevices = JSON.parse(
+ window.localStorage.getItem("audioDevices") || "[]"
+ ) as MediaDeviceInfo[];
- return { audioDevices, videoDevices };
+ return { audioDevices, videoDevices };
+ }
};
export const getSelectedVideoProperties = async () => {
- const videoDeviceProperties = JSON.parse(
- window.localStorage.getItem("videoDeviceProperties") || "{}"
- );
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
+ const videoDeviceProperties = JSON.parse(
+ window.localStorage.getItem("videoDeviceProperties") || "{}"
+ );
- return videoDeviceProperties;
+ return videoDeviceProperties;
+ }
};
diff --git a/apps/web/app/api/session/request/route.ts b/apps/web/app/api/desktop/session/request/route.ts
similarity index 100%
rename from apps/web/app/api/session/request/route.ts
rename to apps/web/app/api/desktop/session/request/route.ts
diff --git a/apps/web/app/api/session/verify/route.ts b/apps/web/app/api/desktop/session/verify/route.ts
similarity index 82%
rename from apps/web/app/api/session/verify/route.ts
rename to apps/web/app/api/desktop/session/verify/route.ts
index 7cd18d1be..4f1bab552 100644
--- a/apps/web/app/api/session/verify/route.ts
+++ b/apps/web/app/api/desktop/session/verify/route.ts
@@ -4,12 +4,6 @@ import { authOptions } from "@cap/database/auth/auth-options";
export async function GET(req: NextRequest) {
const session = await getServerSession(authOptions);
- const cookies = req.cookies;
-
- console.log("req:::::", req);
-
- console.log("session:::::", session);
- console.log("cookies:::::", cookies);
if (session) {
return new Response(
diff --git a/apps/web/app/api/desktop/video/create/route.ts b/apps/web/app/api/desktop/video/create/route.ts
new file mode 100644
index 000000000..7b32ca050
--- /dev/null
+++ b/apps/web/app/api/desktop/video/create/route.ts
@@ -0,0 +1,44 @@
+import { type NextRequest } from "next/server";
+import { db } from "@cap/database";
+import { videos } from "@cap/database/schema";
+import { getCurrentUser } from "@cap/database/auth/session";
+import { nanoId } from "@cap/database/helpers";
+
+export async function GET(req: NextRequest) {
+ const user = await getCurrentUser();
+ const awsRegion = process.env.CAP_AWS_REGION;
+ const awsBucket = process.env.CAP_AWS_BUCKET;
+
+ if (!user) {
+ return new Response(JSON.stringify({ error: true }), {
+ status: 401,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ });
+ }
+
+ const id = nanoId();
+
+ await db.insert(videos).values({
+ id: id,
+ ownerId: user.userId,
+ awsRegion: awsRegion,
+ awsBucket: awsBucket,
+ });
+
+ return new Response(
+ JSON.stringify({
+ id: id,
+ user_id: user.userId,
+ aws_region: awsRegion,
+ aws_bucket: awsBucket,
+ }),
+ {
+ status: 200,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+}
diff --git a/apps/web/app/api/upload/new/route.ts b/apps/web/app/api/upload/new/route.ts
index a31584587..355ba93e6 100644
--- a/apps/web/app/api/upload/new/route.ts
+++ b/apps/web/app/api/upload/new/route.ts
@@ -1,6 +1,5 @@
import { S3Client } from "@aws-sdk/client-s3";
import { createPresignedPost, PresignedPost } from "@aws-sdk/s3-presigned-post";
-import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { NextRequest } from "next/server";
const s3Client = new S3Client({
diff --git a/apps/web/app/share/[videoId]/Share.tsx b/apps/web/app/share/[videoId]/Share.tsx
index 52b1df37f..237794e43 100644
--- a/apps/web/app/share/[videoId]/Share.tsx
+++ b/apps/web/app/share/[videoId]/Share.tsx
@@ -1,17 +1,18 @@
"use client";
-import type { Database } from "@cap/utils";
-export const Share = async ({
- data,
-}: {
- data: Database["public"]["Tables"]["videos"]["Row"] | null;
-}) => {
+import { videos } from "@cap/database/schema";
+import { ShareHeader } from "./_components/ShareHeader";
+import { ShareVideo } from "./_components/ShareVideo";
+
+export const Share = async ({ data }: { data: typeof videos.$inferSelect }) => {
return (
- <div className="wrapper py-24">
- <h1 className="text-2xl mb-3 text-center">
- My Video: 2024-01-12 17:32:54
- </h1>
- <div className="w-full max-w-[500px] h-96 mx-auto bg-gray-100 rounded-xl"></div>
+ <div className="wrapper py-6">
+ <div className="space-y-8">
+ <ShareHeader title={data.name} />
+ <ShareVideo
+ data={{ title: data.name, created: data.createdAt.toISOString() }}
+ />
+ </div>
</div>
);
};
diff --git a/apps/web/app/share/[videoId]/_components/ShareHeader.tsx b/apps/web/app/share/[videoId]/_components/ShareHeader.tsx
new file mode 100644
index 000000000..5c5364cc2
--- /dev/null
+++ b/apps/web/app/share/[videoId]/_components/ShareHeader.tsx
@@ -0,0 +1,9 @@
+import { Logo } from "@cap/ui";
+
+export const ShareHeader = ({ title }: { title: string }) => {
+ return (
+ <div>
+ <Logo className="w-20 h-auto" />
+ </div>
+ );
+};
diff --git a/apps/web/app/share/[videoId]/_components/ShareVideo.tsx b/apps/web/app/share/[videoId]/_components/ShareVideo.tsx
new file mode 100644
index 000000000..a7676a124
--- /dev/null
+++ b/apps/web/app/share/[videoId]/_components/ShareVideo.tsx
@@ -0,0 +1,18 @@
+import moment from "moment";
+
+interface ShareVideoProps {
+ title: string;
+ created: string;
+}
+
+export const ShareVideo = ({ data }: { data: ShareVideoProps }) => {
+ return (
+ <div>
+ <div className="w-full aspect-video mx-auto bg-gray-100 rounded-xl mb-4"></div>
+ <h1 className="text-2xl">{data.title}</h1>
+ <p className="text-base text-gray-500">
+ {moment(data.created).fromNow()}
+ </p>
+ </div>
+ );
+};
diff --git a/apps/web/app/share/[videoId]/page.tsx b/apps/web/app/share/[videoId]/page.tsx
index eefbdd6a4..c67d64c4d 100644
--- a/apps/web/app/share/[videoId]/page.tsx
+++ b/apps/web/app/share/[videoId]/page.tsx
@@ -1,20 +1,25 @@
"use server";
import { Share } from "./Share";
-// import { createSupabaseServerClient } from "@/utils/database/supabase/server";
import { uuidFormat } from "@cap/utils";
+import { db } from "@cap/database";
+import { eq } from "drizzle-orm";
+import { videos } from "@cap/database/schema";
type Props = {
params: { [key: string]: string | string[] | undefined };
};
-//TODO: Auth
-
export default async function ShareVideoPage(props: Props) {
- // const supabase = await createSupabaseServerClient();
const params = props.params;
const videoId = uuidFormat(params.videoId as string);
- // const video = await supabase.from("videos").select("*").eq("id", videoId);
+ const query = await db.select().from(videos).where(eq(videos.id, videoId));
+
+ if (query.length === 0) {
+ return <p>No video found</p>;
+ }
+
+ const video = query[0];
- return <Share data={null} />;
+ return <Share data={video} />;
}
diff --git a/apps/web/app/share/loading.tsx b/apps/web/app/share/loading.tsx
new file mode 100644
index 000000000..972527c43
--- /dev/null
+++ b/apps/web/app/share/loading.tsx
@@ -0,0 +1,7 @@
+"use client";
+
+import { SkeletonPage } from "@cap/ui";
+
+export default function Loading() {
+ return <SkeletonPage />;
+}
diff --git a/apps/web/app/share/page.tsx b/apps/web/app/share/page.tsx
index 09f1e670d..1f49e29e6 100644
--- a/apps/web/app/share/page.tsx
+++ b/apps/web/app/share/page.tsx
@@ -1,9 +1,6 @@
-"use client";
-import { useRouter } from "next/navigation";
+"use server";
+import { redirect } from "next/navigation";
-export default function SharePage() {
- const router = useRouter();
- if (typeof window !== "undefined") {
- router.replace("/");
- }
+export default async function SharePage() {
+ redirect("/");
}
diff --git a/apps/web/components/Footer.tsx b/apps/web/components/Footer.tsx
index 289a5e632..3a024b885 100644
--- a/apps/web/components/Footer.tsx
+++ b/apps/web/components/Footer.tsx
@@ -5,7 +5,12 @@ import { usePathname } from "next/navigation";
export const Footer = () => {
const pathname = usePathname();
- if (pathname === "/login" || pathname.includes("/dashboard")) return null;
+ if (
+ pathname === "/login" ||
+ pathname.includes("/dashboard") ||
+ pathname.includes("/share")
+ )
+ return null;
return (
<footer className="py-4 border-t">
diff --git a/apps/web/components/Navbar.tsx b/apps/web/components/Navbar.tsx
index 6026e87cc..769f0197c 100644
--- a/apps/web/components/Navbar.tsx
+++ b/apps/web/components/Navbar.tsx
@@ -7,7 +7,12 @@ export const Navbar = () => {
const pathname = usePathname();
const isHomePage = pathname === "/";
- if (pathname === "/login" || pathname.includes("/dashboard")) return null;
+ if (
+ pathname === "/login" ||
+ pathname.includes("/dashboard") ||
+ pathname.includes("/share")
+ )
+ return null;
return (
<nav
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index 259707024..f7f550538 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -25,7 +25,7 @@ const nextConfig = {
async headers() {
return [
{
- source: "/api/session/(.*)",
+ source: "/api/desktop/(.*)",
headers: [
{
key: "Access-Control-Allow-Origin",
diff --git a/apps/web/package.json b/apps/web/package.json
index adea981af..19dd813c6 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -23,8 +23,10 @@
"clsx": "^2.0.0",
"cookies-next": "^4.1.0",
"dotenv": "^16.3.1",
+ "drizzle-orm": "^0.29.3",
"lucide-react": "^0.294.0",
"million": "^2.6.4",
+ "moment": "^2.30.1",
"next": "14.1.0",
"next-auth": "^4.24.5",
"nextjs-cors": "^2.2.0",
diff --git a/packages/database/schema.ts b/packages/database/schema.ts
index b7083df3b..2c05068f1 100644
--- a/packages/database/schema.ts
+++ b/packages/database/schema.ts
@@ -137,14 +137,12 @@ export const videos = mysqlTable(
id: nanoId("id").notNull().primaryKey().unique(),
ownerId: nanoId("ownerId").notNull(),
name: varchar("name", { length: 255 }).notNull().default("My Video"),
- s3Url: text("s3Url"),
awsRegion: varchar("awsRegion", { length: 255 }),
awsBucket: varchar("awsBucket", { length: 255 }),
thumbnailUrl: text("thumbnailUrl"),
duration: int("duration"),
metadata: json("metadata"),
- complete: int("complete").notNull().default(1),
- isPublic: int("isPublic").notNull().default(0),
+ isPublic: int("isPublic").notNull().default(1),
createdAt: timestamp("createdAt").notNull().defaultNow(),
updatedAt: timestamp("updatedAt").notNull().defaultNow().onUpdateNow(),
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 728033219..4162e9196 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -141,12 +141,18 @@ importers:
dotenv:
specifier: ^16.3.1
version: 16.3.1
+ drizzle-orm:
+ specifier: ^0.29.3
lucide-react:
specifier: ^0.294.0
version: 0.294.0([email protected])
million:
specifier: ^2.6.4
version: 2.6.4
+ moment:
+ specifier: ^2.30.1
+ version: 2.30.1
next:
specifier: 14.1.0
@@ -7473,6 +7479,10 @@ packages:
minimist: 1.2.8
dev: true
+ resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
+ dev: false
+
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}