Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

use t3-env (#286)

Brendan Allan0562599ff197
diff --git a/.env.example b/.env.example
index 0cb3f9d2b..ba9f7d0ee 100644
--- a/.env.example
+++ b/.env.example
@@ -13,6 +13,7 @@ VITE_SERVER_URL=${NEXT_PUBLIC_WEB_URL}
# only @cap/desktop
# VITE_SERVER_URL=https://cap.so
+CAP_DESKTOP_SENTRY_URL=
RUST_BACKTRACE=full
@@ -32,9 +33,9 @@ DATABASE_URL='mysql://root:@localhost:3306/planetscale'
# DATABASE_URL='https://{username}:{password}@aws.connect.psdb.cloud/{db-name}' # https:// identifies this as a PS connection string
# DATABASE_MIGRATION_URL='mysql://{username}:{password}@aws.connect.psdb.cloud/{db-name}?ssl={"rejectUnauthorized":false}' # necessary as migrations can't be performed over https
-# Encrypts users' custom S3 credentials. If you don't plan on using this feature you can leave it commented out.
+# Encrypts users' custom S3 credentials.
# Generate a value by running `openssl rand -hex 32`
-# DATABASE_ENCRYPTION_KEY=
+DATABASE_ENCRYPTION_KEY=
## AWS/S3
diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs
index 2075dc3f3..1326763dd 100644
--- a/apps/desktop/src-tauri/src/main.rs
+++ b/apps/desktop/src-tauri/src/main.rs
@@ -5,33 +5,37 @@ use std::sync::Arc;
fn main() {
// We have to hold onto the ClientInitGuard until the very end
- let _guard = sentry::init((
- dotenvy_macro::dotenv!("CAP_DESKTOP_SENTRY_URL"),
- sentry::ClientOptions {
- release: sentry::release_name!(),
- debug: cfg!(debug_assertions),
- before_send: Some(Arc::new(|mut event| {
- // this is irrelevant to us + users probably don't want us knowing their computer names
- event.server_name = None;
+ let _guard = if dotenvy_macro::dotenv!("CAP_DESKTOP_SENTRY_URL") != "" {
+ Some(sentry::init((
+ dotenvy_macro::dotenv!("CAP_DESKTOP_SENTRY_URL"),
+ sentry::ClientOptions {
+ release: sentry::release_name!(),
+ debug: cfg!(debug_assertions),
+ before_send: Some(Arc::new(|mut event| {
+ // this is irrelevant to us + users probably don't want us knowing their computer names
+ event.server_name = None;
- #[cfg(debug_assertions)]
- {
- let msg = event.message.clone().unwrap_or("No message".into());
- println!("Sentry captured {}: {}", &event.level, &msg);
- println!("-- user: {:?}", &event.user);
- println!("-- event tags: {:?}", &event.tags);
- println!("-- event contexts: {:?}", &event.contexts);
- None
- }
+ #[cfg(debug_assertions)]
+ {
+ let msg = event.message.clone().unwrap_or("No message".into());
+ println!("Sentry captured {}: {}", &event.level, &msg);
+ println!("-- user: {:?}", &event.user);
+ println!("-- event tags: {:?}", &event.tags);
+ println!("-- event contexts: {:?}", &event.contexts);
+ None
+ }
- #[cfg(not(debug_assertions))]
- {
- Some(event)
- }
- })),
- ..Default::default()
- },
- ));
+ #[cfg(not(debug_assertions))]
+ {
+ Some(event)
+ }
+ })),
+ ..Default::default()
+ },
+ )))
+ } else {
+ None
+ };
#[cfg(debug_assertions)]
sentry::configure_scope(|scope| {
diff --git a/apps/embed/package.json b/apps/embed/package.json
index fe8bc9f02..d84127db4 100644
--- a/apps/embed/package.json
+++ b/apps/embed/package.json
@@ -32,7 +32,7 @@
"react-tooltip": "^5.26.3",
"server-only": "^0.0.1",
"subtitles-parser-vtt": "^0.1.0",
- "zod": "^3.22.4"
+ "zod": "^3.24.1"
},
"devDependencies": {
"@types/node": "^20.11.5",
diff --git a/apps/web/app/api/desktop/feedback/route.ts b/apps/web/app/api/desktop/feedback/route.ts
index 468606075..296fb2b1e 100644
--- a/apps/web/app/api/desktop/feedback/route.ts
+++ b/apps/web/app/api/desktop/feedback/route.ts
@@ -1,9 +1,10 @@
import { type NextRequest } from "next/server";
import { getCurrentUser } from "@cap/database/auth/session";
import { cookies } from "next/headers";
+import { serverEnv, clientEnv } from "@cap/env";
const allowedOrigins = [
- process.env.NEXT_PUBLIC_WEB_URL,
+ clientEnv.NEXT_PUBLIC_WEB_URL,
"http://localhost:3001",
"http://localhost:3000",
"tauri://localhost",
@@ -92,7 +93,7 @@ export async function POST(req: NextRequest) {
try {
// Send feedback to Discord channel
- const discordWebhookUrl = process.env.DISCORD_FEEDBACK_WEBHOOK_URL;
+ const discordWebhookUrl = serverEnv.DISCORD_FEEDBACK_WEBHOOK_URL;
if (!discordWebhookUrl) {
throw new Error("Discord webhook URL is not configured");
}
diff --git a/apps/web/app/api/desktop/plan/route.ts b/apps/web/app/api/desktop/plan/route.ts
index db9b844ae..b078e280b 100644
--- a/apps/web/app/api/desktop/plan/route.ts
+++ b/apps/web/app/api/desktop/plan/route.ts
@@ -7,9 +7,10 @@ import { cookies } from "next/headers";
import { isUserOnProPlan } from "@cap/utils";
import { stripe } from "@cap/utils";
import { eq } from "drizzle-orm";
+import { clientEnv } from "@cap/env";
const allowedOrigins = [
- process.env.NEXT_PUBLIC_WEB_URL,
+ clientEnv.NEXT_PUBLIC_WEB_URL,
"http://localhost:3001",
"tauri://localhost",
"http://tauri.localhost",
diff --git a/apps/web/app/api/desktop/session/request/route.ts b/apps/web/app/api/desktop/session/request/route.ts
index dc374f99d..4061b16ac 100644
--- a/apps/web/app/api/desktop/session/request/route.ts
+++ b/apps/web/app/api/desktop/session/request/route.ts
@@ -3,6 +3,7 @@ import { getServerSession } from "next-auth";
import { authOptions } from "@cap/database/auth/auth-options";
import { decode } from "next-auth/jwt";
import { getCurrentUser } from "@cap/database/auth/session";
+import { clientEnv, serverEnv } from "@cap/env";
export async function GET(req: NextRequest) {
const searchParams = req.nextUrl.searchParams;
@@ -10,12 +11,11 @@ export async function GET(req: NextRequest) {
const port = searchParams.get("port") || "";
const platform = searchParams.get("platform") || "web";
- const secret = process.env.NEXTAUTH_SECRET;
+ const secret = serverEnv.NEXTAUTH_SECRET;
+ const loginRedirectUrl = `${clientEnv.NEXT_PUBLIC_WEB_URL}/login?next=${clientEnv.NEXT_PUBLIC_WEB_URL}/api/desktop/session/request?port=${port}`;
if (!session) {
- return Response.redirect(
- `${process.env.NEXT_PUBLIC_WEB_URL}/login?next=${process.env.NEXT_PUBLIC_WEB_URL}/api/desktop/session/request?port=${port}`
- );
+ return Response.redirect(loginRedirectUrl);
}
const token = req.cookies.get("next-auth.session-token") ?? null;
@@ -23,9 +23,7 @@ export async function GET(req: NextRequest) {
const user = await getCurrentUser();
if (!tokenValue || !user) {
- return Response.redirect(
- `${process.env.NEXT_PUBLIC_WEB_URL}/login?next=${process.env.NEXT_PUBLIC_WEB_URL}/api/desktop/session/request?port=${port}`
- );
+ return Response.redirect(loginRedirectUrl);
}
const decodedToken = await decode({
@@ -34,9 +32,7 @@ export async function GET(req: NextRequest) {
});
if (!decodedToken) {
- return Response.redirect(
- `${process.env.NEXT_PUBLIC_WEB_URL}/login?next=${process.env.NEXT_PUBLIC_WEB_URL}/api/desktop/session/request?port=${port}`
- );
+ return Response.redirect(loginRedirectUrl);
}
const params = `token=${tokenValue}&expires=${decodedToken?.exp}&user_id=${user.id}`;
diff --git a/apps/web/app/api/desktop/subscribe/route.ts b/apps/web/app/api/desktop/subscribe/route.ts
index e9d450919..d96fe2ac5 100644
--- a/apps/web/app/api/desktop/subscribe/route.ts
+++ b/apps/web/app/api/desktop/subscribe/route.ts
@@ -5,9 +5,10 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { cookies } from "next/headers";
import { isUserOnProPlan, stripe } from "@cap/utils";
import { eq } from "drizzle-orm";
+import { clientEnv } from "@cap/env";
const allowedOrigins = [
- process.env.NEXT_PUBLIC_WEB_URL,
+ clientEnv.NEXT_PUBLIC_WEB_URL,
"http://localhost:3001",
"tauri://localhost",
"http://tauri.localhost",
@@ -155,8 +156,8 @@ export async function POST(request: NextRequest) {
},
],
mode: "subscription",
- success_url: `${process.env.NEXT_PUBLIC_WEB_URL}/dashboard/caps?upgrade=true`,
- cancel_url: `${process.env.NEXT_PUBLIC_WEB_URL}/pricing`,
+ success_url: `${clientEnv.NEXT_PUBLIC_WEB_URL}/dashboard/caps?upgrade=true`,
+ cancel_url: `${clientEnv.NEXT_PUBLIC_WEB_URL}/pricing`,
allow_promotion_codes: true,
});
diff --git a/apps/web/app/api/desktop/video/create/route.ts b/apps/web/app/api/desktop/video/create/route.ts
index 3baaf9205..3c7ce3f04 100644
--- a/apps/web/app/api/desktop/video/create/route.ts
+++ b/apps/web/app/api/desktop/video/create/route.ts
@@ -7,9 +7,10 @@ import { cookies } from "next/headers";
import { dub } from "@/utils/dub";
import { eq } from "drizzle-orm";
import { getS3Bucket, getS3Config } from "@/utils/s3";
+import { clientEnv, NODE_ENV } from "@cap/env";
const allowedOrigins = [
- process.env.NEXT_PUBLIC_WEB_URL,
+ clientEnv.NEXT_PUBLIC_WEB_URL,
"http://localhost:3001",
"http://localhost:3000",
"tauri://localhost",
@@ -187,14 +188,9 @@ export async function GET(req: NextRequest) {
await db.insert(videos).values(videoData);
- if (process.env.NEXT_PUBLIC_IS_CAP && process.env.NODE_ENV === "production") {
- console.log({
- url: `${process.env.NEXT_PUBLIC_WEB_URL}/s/${id}`,
- domain: "cap.link",
- key: id,
- });
+ if (clientEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production") {
await dub.links.create({
- url: `${process.env.NEXT_PUBLIC_WEB_URL}/s/${id}`,
+ url: `${clientEnv.NEXT_PUBLIC_WEB_URL}/s/${id}`,
domain: "cap.link",
key: id,
});
diff --git a/apps/web/app/api/playlist/route.ts b/apps/web/app/api/playlist/route.ts
index fc474ecc6..efa3b836a 100644
--- a/apps/web/app/api/playlist/route.ts
+++ b/apps/web/app/api/playlist/route.ts
@@ -16,6 +16,7 @@ import {
import { getHeaders, CACHE_CONTROL_HEADERS } from "@/utils/helpers";
import { createS3Client, getS3Bucket } from "@/utils/s3";
import { S3_BUCKET_URL } from "@cap/utils";
+import { clientEnv } from "@cap/env";
export const revalidate = 3599;
@@ -82,7 +83,7 @@ export async function GET(request: NextRequest) {
const Bucket = await getS3Bucket(bucket);
const s3Client = await createS3Client(bucket);
- if (!bucket || video.awsBucket === process.env.NEXT_PUBLIC_CAP_AWS_BUCKET) {
+ if (!bucket || video.awsBucket === clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET) {
if (video.source.type === "desktopMP4") {
return new Response(null, {
status: 302,
@@ -282,9 +283,9 @@ export async function GET(request: NextRequest) {
const generatedPlaylist = await generateMasterPlaylist(
videoMetadata?.Metadata?.resolution ?? "",
videoMetadata?.Metadata?.bandwidth ?? "",
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${userId}&videoId=${videoId}&videoType=video`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${userId}&videoId=${videoId}&videoType=video`,
audioMetadata
- ? `${process.env.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${userId}&videoId=${videoId}&videoType=audio`
+ ? `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${userId}&videoId=${videoId}&videoType=audio`
: null,
video.xStreamInfo ?? ""
);
diff --git a/apps/web/app/api/screenshot/route.ts b/apps/web/app/api/screenshot/route.ts
index d86895760..0025e6d58 100644
--- a/apps/web/app/api/screenshot/route.ts
+++ b/apps/web/app/api/screenshot/route.ts
@@ -12,6 +12,7 @@ import { getHeaders } from "@/utils/helpers";
import { createS3Client, getS3Bucket } from "@/utils/s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { S3_BUCKET_URL } from "@cap/utils";
+import { clientEnv } from "@cap/env";
export const revalidate = 0;
@@ -100,7 +101,7 @@ export async function GET(request: NextRequest) {
let screenshotUrl: string;
- if (video.awsBucket !== process.env.NEXT_PUBLIC_CAP_AWS_BUCKET) {
+ if (video.awsBucket !== clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET) {
screenshotUrl = await getSignedUrl(
s3Client,
new GetObjectCommand({
diff --git a/apps/web/app/api/settings/billing/manage/route.ts b/apps/web/app/api/settings/billing/manage/route.ts
index 029af11ce..fdee85d6c 100644
--- a/apps/web/app/api/settings/billing/manage/route.ts
+++ b/apps/web/app/api/settings/billing/manage/route.ts
@@ -4,6 +4,7 @@ import { NextRequest, NextResponse } from "next/server";
import { eq } from "drizzle-orm";
import { db } from "@cap/database";
import { users } from "@cap/database/schema";
+import { clientEnv } from "@cap/env";
export async function POST(request: NextRequest) {
const user = await getCurrentUser();
@@ -35,7 +36,7 @@ export async function POST(request: NextRequest) {
const { url } = await stripe.billingPortal.sessions.create({
customer: customerId as string,
- return_url: `${process.env.NEXT_PUBLIC_WEB_URL}/dashboard/settings/workspace`,
+ return_url: `${clientEnv.NEXT_PUBLIC_WEB_URL}/dashboard/settings/workspace`,
});
return NextResponse.json(url);
}
diff --git a/apps/web/app/api/settings/billing/subscribe/route.ts b/apps/web/app/api/settings/billing/subscribe/route.ts
index 47e385632..eb48f93e9 100644
--- a/apps/web/app/api/settings/billing/subscribe/route.ts
+++ b/apps/web/app/api/settings/billing/subscribe/route.ts
@@ -4,6 +4,7 @@ import { NextRequest } from "next/server";
import { eq } from "drizzle-orm";
import { db } from "@cap/database";
import { users } from "@cap/database/schema";
+import { clientEnv } from "@cap/env";
export async function POST(request: NextRequest) {
console.log("Starting subscription process");
@@ -61,8 +62,8 @@ export async function POST(request: NextRequest) {
customer: customerId as string,
line_items: [{ price: priceId, quantity: quantity }],
mode: "subscription",
- success_url: `${process.env.NEXT_PUBLIC_WEB_URL}/dashboard/caps?upgrade=true`,
- cancel_url: `${process.env.NEXT_PUBLIC_WEB_URL}/pricing`,
+ success_url: `${clientEnv.NEXT_PUBLIC_WEB_URL}/dashboard/caps?upgrade=true`,
+ cancel_url: `${clientEnv.NEXT_PUBLIC_WEB_URL}/pricing`,
allow_promotion_codes: true,
});
diff --git a/apps/web/app/api/settings/workspace/invite/send/route.ts b/apps/web/app/api/settings/workspace/invite/send/route.ts
index 9b1abab79..ad41a97a4 100644
--- a/apps/web/app/api/settings/workspace/invite/send/route.ts
+++ b/apps/web/app/api/settings/workspace/invite/send/route.ts
@@ -6,6 +6,7 @@ import { eq } from "drizzle-orm";
import { nanoId } from "@cap/database/helpers";
import { sendEmail } from "@cap/database/emails/config";
import { WorkspaceInvite } from "@cap/database/emails/workspace-invite";
+import { clientEnv } from "@cap/env";
export async function POST(request: NextRequest) {
console.log("POST request received for workspace invite");
@@ -49,7 +50,7 @@ export async function POST(request: NextRequest) {
});
// Send invitation email
- const inviteUrl = `${process.env.NEXT_PUBLIC_WEB_URL}/invite/${inviteId}`;
+ const inviteUrl = `${clientEnv.NEXT_PUBLIC_WEB_URL}/invite/${inviteId}`;
await sendEmail({
email: email.trim(),
subject: `Invitation to join ${space[0].name} on Cap`,
diff --git a/apps/web/app/api/thumbnail/route.ts b/apps/web/app/api/thumbnail/route.ts
index 446fcddaf..4972769b2 100644
--- a/apps/web/app/api/thumbnail/route.ts
+++ b/apps/web/app/api/thumbnail/route.ts
@@ -7,6 +7,7 @@ import { s3Buckets, videos } from "@cap/database/schema";
import { createS3Client, getS3Bucket } from "@/utils/s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { S3_BUCKET_URL } from "@cap/utils";
+import { clientEnv } from "@cap/env";
export const revalidate = 0;
@@ -66,7 +67,7 @@ export async function GET(request: NextRequest) {
if (
!result.bucket ||
- video.awsBucket === process.env.NEXT_PUBLIC_CAP_AWS_BUCKET
+ video.awsBucket === clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET
) {
thumbnailUrl = `${S3_BUCKET_URL}/${prefix}screenshot/screen-capture.jpg`;
return new Response(JSON.stringify({ screen: thumbnailUrl }), {
diff --git a/apps/web/app/api/upload/mux/create/route.ts b/apps/web/app/api/upload/mux/create/route.ts
index ab471574d..6d721d6ae 100644
--- a/apps/web/app/api/upload/mux/create/route.ts
+++ b/apps/web/app/api/upload/mux/create/route.ts
@@ -8,8 +8,10 @@ import {
CreateJobCommand,
} from "@aws-sdk/client-mediaconvert";
import { createS3Client, getS3Bucket } from "@/utils/s3";
+import { serverEnv, clientEnv } from "@cap/env";
+
const allowedOrigins = [
- process.env.NEXT_PUBLIC_WEB_URL,
+ clientEnv.NEXT_PUBLIC_WEB_URL,
"http://localhost:3001",
"tauri://localhost",
"http://tauri.localhost",
@@ -172,17 +174,17 @@ export async function GET(request: NextRequest) {
);
const mediaConvertClient = new MediaConvertClient({
- region: process.env.NEXT_PUBLIC_CAP_AWS_REGION || "",
+ region: clientEnv.NEXT_PUBLIC_CAP_AWS_REGION || "",
credentials: {
- accessKeyId: process.env.CAP_AWS_ACCESS_KEY || "",
- secretAccessKey: process.env.CAP_AWS_SECRET_KEY || "",
+ accessKeyId: serverEnv.CAP_AWS_ACCESS_KEY || "",
+ secretAccessKey: serverEnv.CAP_AWS_SECRET_KEY || "",
},
});
const outputKey = `${userId}/${videoId}/output/`;
const createJobCommand = new CreateJobCommand({
- Role: process.env.CAP_AWS_MEDIACONVERT_ROLE_ARN || "",
+ Role: serverEnv.CAP_AWS_MEDIACONVERT_ROLE_ARN || "",
Settings: {
Inputs: videoSegmentKeys.map((videoSegmentKey, index) => {
const audioSegmentKey = audioSegmentKeys[index];
diff --git a/apps/web/app/api/upload/mux/status/route.ts b/apps/web/app/api/upload/mux/status/route.ts
index 8254dd9b8..be1b30216 100644
--- a/apps/web/app/api/upload/mux/status/route.ts
+++ b/apps/web/app/api/upload/mux/status/route.ts
@@ -6,9 +6,10 @@ import {
MediaConvertClient,
GetJobCommand,
} from "@aws-sdk/client-mediaconvert";
+import { serverEnv, clientEnv } from "@cap/env";
const allowedOrigins = [
- process.env.NEXT_PUBLIC_WEB_URL,
+ clientEnv.NEXT_PUBLIC_WEB_URL,
"http://localhost:3001",
"tauri://localhost",
"http://tauri.localhost",
@@ -117,10 +118,10 @@ export async function GET(request: NextRequest) {
}
const mediaConvertClient = new MediaConvertClient({
- region: process.env.NEXT_PUBLIC_CAP_AWS_REGION || "",
+ region: clientEnv.NEXT_PUBLIC_CAP_AWS_REGION || "",
credentials: {
- accessKeyId: process.env.CAP_AWS_ACCESS_KEY || "",
- secretAccessKey: process.env.CAP_AWS_SECRET_KEY || "",
+ accessKeyId: serverEnv.CAP_AWS_ACCESS_KEY || "",
+ secretAccessKey: serverEnv.CAP_AWS_SECRET_KEY || "",
},
});
diff --git a/apps/web/app/api/upload/new/route.ts b/apps/web/app/api/upload/new/route.ts
index b4f10da89..0d36064c7 100644
--- a/apps/web/app/api/upload/new/route.ts
+++ b/apps/web/app/api/upload/new/route.ts
@@ -1,6 +1,7 @@
import { type NextRequest } from "next/server";
import { getCurrentUser } from "@cap/database/auth/session";
import { uploadToS3 } from "@/utils/video/upload/helpers";
+import { clientEnv } from "@cap/env";
export async function POST(request: NextRequest) {
const user = await getCurrentUser();
@@ -13,8 +14,8 @@ export async function POST(request: NextRequest) {
const videoCodec = formData.get("videoCodec");
const audioCodec = formData.get("audioCodec");
- const awsRegion = process.env.NEXT_PUBLIC_CAP_AWS_REGION;
- const awsBucket = process.env.NEXT_PUBLIC_CAP_AWS_BUCKET;
+ const awsRegion = clientEnv.NEXT_PUBLIC_CAP_AWS_REGION;
+ const awsBucket = clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET;
if (!user || !awsRegion || !awsBucket || !filename || !blobData) {
console.error("Missing required data in /api/upload/new/route.ts");
diff --git a/apps/web/app/api/upload/signed/route.ts b/apps/web/app/api/upload/signed/route.ts
index b2672eb68..d3a226b80 100644
--- a/apps/web/app/api/upload/signed/route.ts
+++ b/apps/web/app/api/upload/signed/route.ts
@@ -13,6 +13,7 @@ import { s3Buckets } from "@cap/database/schema";
import { eq } from "drizzle-orm";
import { cookies } from "next/headers";
import type { NextRequest } from "next/server";
+import { clientEnv, serverEnv } from "@cap/env";
export async function POST(request: NextRequest) {
try {
@@ -64,17 +65,17 @@ export async function POST(request: NextRequest) {
if (
!bucket ||
!s3Config ||
- bucket.bucketName !== process.env.CAP_S3_BUCKET
+ bucket.bucketName !== clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET
) {
- const distributionId = process.env.CAP_CLOUDFRONT_DISTRIBUTION_ID;
+ const distributionId = serverEnv.CAP_CLOUDFRONT_DISTRIBUTION_ID;
if (distributionId) {
console.log("Creating CloudFront invalidation for", fileKey);
const cloudfront = new CloudFrontClient({
- region: process.env.NEXT_PUBLIC_CAP_AWS_REGION || "us-east-1",
+ region: clientEnv.NEXT_PUBLIC_CAP_AWS_REGION || "us-east-1",
credentials: {
- accessKeyId: process.env.CAP_AWS_ACCESS_KEY || "",
- secretAccessKey: process.env.CAP_AWS_SECRET_KEY || "",
+ accessKeyId: serverEnv.CAP_AWS_ACCESS_KEY || "",
+ secretAccessKey: serverEnv.CAP_AWS_SECRET_KEY || "",
},
});
@@ -144,9 +145,9 @@ export async function POST(request: NextRequest) {
);
// When not using aws s3, we need to transform the url to the local endpoint
- if (process.env.NEXT_PUBLIC_CAP_AWS_ENDPOINT) {
- const endpoint = process.env.NEXT_PUBLIC_CAP_AWS_ENDPOINT;
- const bucket = process.env.NEXT_PUBLIC_CAP_AWS_BUCKET;
+ if (clientEnv.NEXT_PUBLIC_CAP_AWS_ENDPOINT) {
+ const endpoint = clientEnv.NEXT_PUBLIC_CAP_AWS_ENDPOINT;
+ const bucket = clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET;
const newUrl = `${endpoint}/${bucket}/`;
presignedPostData.url = newUrl;
}
@@ -157,7 +158,7 @@ export async function POST(request: NextRequest) {
const videoId = fileKey.split("/")[1]; // Assuming fileKey format is userId/videoId/...
if (videoId) {
try {
- await fetch(`${process.env.NEXT_PUBLIC_WEB_URL}/api/revalidate`, {
+ await fetch(`${clientEnv.NEXT_PUBLIC_WEB_URL}/api/revalidate`, {
method: "POST",
headers: {
"Content-Type": "application/json",
diff --git a/apps/web/app/api/video/[videoId]/route.ts b/apps/web/app/api/video/[videoId]/route.ts
index e2290f0cc..8d6e480aa 100644
--- a/apps/web/app/api/video/[videoId]/route.ts
+++ b/apps/web/app/api/video/[videoId]/route.ts
@@ -1,6 +1,7 @@
import { db } from "@cap/database";
import { s3Buckets, videos } from "@cap/database/schema";
import { eq } from "drizzle-orm";
+import { serverEnv, clientEnv } from "@cap/env";
import { NextResponse } from "next/server";
export async function GET(
@@ -28,14 +29,14 @@ export async function GET(
}
const defaultBucket = {
- name: process.env.NEXT_PUBLIC_CAP_AWS_BUCKET,
- region: process.env.NEXT_PUBLIC_CAP_AWS_REGION,
- accessKeyId: process.env.CAP_AWS_ACCESS_KEY,
- secretAccessKey: process.env.CAP_AWS_SECRET_KEY,
+ name: clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET,
+ region: clientEnv.NEXT_PUBLIC_CAP_AWS_REGION,
+ accessKeyId: serverEnv.CAP_AWS_ACCESS_KEY,
+ secretAccessKey: serverEnv.CAP_AWS_SECRET_KEY,
};
return NextResponse.json({
video: result.video,
bucket: result.bucket || defaultBucket,
});
-}
\ No newline at end of file
+}
diff --git a/apps/web/app/api/video/og/route.tsx b/apps/web/app/api/video/og/route.tsx
index 8c69cef80..157c7b6e3 100644
--- a/apps/web/app/api/video/og/route.tsx
+++ b/apps/web/app/api/video/og/route.tsx
@@ -3,6 +3,7 @@ import { NextRequest } from "next/server";
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { createS3Client, getS3Bucket } from "@/utils/s3";
+import { clientEnv } from "@cap/env";
export const runtime = "edge";
@@ -10,7 +11,7 @@ export async function GET(req: NextRequest) {
const videoId = req.nextUrl.searchParams.get("videoId") as string;
const response = await fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/video/${videoId}`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/video/${videoId}`,
{
method: "GET",
headers: {
diff --git a/apps/web/app/api/video/playlistUrl/route.ts b/apps/web/app/api/video/playlistUrl/route.ts
index d43c7637d..f6ce15aa6 100644
--- a/apps/web/app/api/video/playlistUrl/route.ts
+++ b/apps/web/app/api/video/playlistUrl/route.ts
@@ -5,6 +5,7 @@ import { eq } from "drizzle-orm";
import { getHeaders } from "@/utils/helpers";
import { CACHE_CONTROL_HEADERS } from "@/utils/helpers";
import { S3_BUCKET_URL } from "@cap/utils";
+import { clientEnv } from "@cap/env";
export const revalidate = 0;
@@ -75,8 +76,8 @@ export async function GET(request: NextRequest) {
return new Response(
JSON.stringify({
- playlistOne: `${process.env.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${video.ownerId}&videoId=${video.id}&videoType=video`,
- playlistTwo: `${process.env.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${video.ownerId}&videoId=${video.id}&videoType=audio`,
+ playlistOne: `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${video.ownerId}&videoId=${video.id}&videoType=video`,
+ playlistTwo: `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${video.ownerId}&videoId=${video.id}&videoType=audio`,
}),
{
status: 200,
diff --git a/apps/web/app/api/video/transcribe/route.ts b/apps/web/app/api/video/transcribe/route.ts
index 2d7cabdcf..5c2f5ac90 100644
--- a/apps/web/app/api/video/transcribe/route.ts
+++ b/apps/web/app/api/video/transcribe/route.ts
@@ -10,7 +10,8 @@ import { getHeaders } from "@/utils/helpers";
import { db } from "@cap/database";
import { s3Buckets, videos } from "@cap/database/schema";
import { eq } from "drizzle-orm";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
+import { createS3Client } from "@/utils/s3";
+import { serverEnv } from "@cap/env";
export const maxDuration = 120;
@@ -29,7 +30,7 @@ export async function GET(request: NextRequest) {
const videoId = searchParams.get("videoId") || "";
const origin = request.headers.get("origin") as string;
- if (!process.env.DEEPGRAM_API_KEY) {
+ if (!serverEnv.DEEPGRAM_API_KEY) {
return new Response(
JSON.stringify({
error: true,
@@ -236,7 +237,7 @@ function formatTimestamp(seconds: number): string {
}
async function transcribeAudio(videoUrl: string): Promise<string> {
- const deepgram = createClient(process.env.DEEPGRAM_API_KEY as string);
+ const deepgram = createClient(serverEnv.DEEPGRAM_API_KEY as string);
const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
{
diff --git a/apps/web/app/api/waitlist/route.ts b/apps/web/app/api/waitlist/route.ts
index ed689f9d6..679b8ec15 100644
--- a/apps/web/app/api/waitlist/route.ts
+++ b/apps/web/app/api/waitlist/route.ts
@@ -1,3 +1,5 @@
+import { serverEnv } from "@cap/env";
+
export async function POST(request: Request) {
const res = await request.json();
const { email } = res;
@@ -12,7 +14,7 @@ export async function POST(request: Request) {
method: "POST",
headers: {
"Content-Type": "application/json",
- Authorization: `Bearer ${process.env.NEXT_LOOPS_KEY}`,
+ Authorization: `Bearer ${serverEnv.NEXT_LOOPS_KEY}`,
},
body: JSON.stringify({
email,
diff --git a/apps/web/app/api/webhooks/stripe/route.ts b/apps/web/app/api/webhooks/stripe/route.ts
index 33403d7dd..3a5077a1e 100644
--- a/apps/web/app/api/webhooks/stripe/route.ts
+++ b/apps/web/app/api/webhooks/stripe/route.ts
@@ -4,6 +4,7 @@ import { users } from "@cap/database/schema";
import { eq } from "drizzle-orm";
import { NextResponse } from "next/server";
import Stripe from "stripe";
+import { serverEnv } from "@cap/env";
const relevantEvents = new Set([
"checkout.session.completed",
@@ -12,10 +13,17 @@ const relevantEvents = new Set([
]);
// Helper function to find user with retries
-async function findUserWithRetry(email: string, userId?: string, maxRetries = 5): Promise<typeof users.$inferSelect | null> {
+async function findUserWithRetry(
+ email: string,
+ userId?: string,
+ maxRetries = 5
+): Promise<typeof users.$inferSelect | null> {
for (let i = 0; i < maxRetries; i++) {
- console.log(`[Attempt ${i + 1}/${maxRetries}] Looking for user:`, { email, userId });
-
+ console.log(`[Attempt ${i + 1}/${maxRetries}] Looking for user:`, {
+ email,
+ userId,
+ });
+
try {
// Try finding by userId first if available
if (userId) {
@@ -25,8 +33,8 @@ async function findUserWithRetry(email: string, userId?: string, maxRetries = 5)
.from(users)
.where(eq(users.id, userId))
.limit(1)
- .then(rows => rows[0] ?? null);
-
+ .then((rows) => rows[0] ?? null);
+
if (userById) {
console.log(`Found user by ID: ${userId}`);
return userById;
@@ -42,47 +50,53 @@ async function findUserWithRetry(email: string, userId?: string, maxRetries = 5)
.from(users)
.where(eq(users.email, email))
.limit(1)
- .then(rows => rows[0] ?? null);
-
+ .then((rows) => rows[0] ?? null);
+
if (userByEmail) {
console.log(`Found user by email: ${email}`);
return userByEmail;
}
console.log(`No user found by email: ${email}`);
}
-
+
// If we reach here, no user was found on this attempt
if (i < maxRetries - 1) {
const delay = Math.pow(2, i) * 3000; // 3s, 6s, 12s, 24s, 48s
- console.log(`No user found on attempt ${i + 1}. Waiting ${delay}ms before retry...`);
- await new Promise(resolve => setTimeout(resolve, delay));
+ console.log(
+ `No user found on attempt ${
+ i + 1
+ }. Waiting ${delay}ms before retry...`
+ );
+ await new Promise((resolve) => setTimeout(resolve, delay));
}
} catch (error) {
console.error(`Error during attempt ${i + 1}:`, error);
// If this is not the last attempt, continue to next retry
if (i < maxRetries - 1) {
const delay = Math.pow(2, i) * 3000;
- await new Promise(resolve => setTimeout(resolve, delay));
+ await new Promise((resolve) => setTimeout(resolve, delay));
continue;
}
}
}
-
- console.log('All attempts exhausted. No user found.');
+
+ console.log("All attempts exhausted. No user found.");
return null;
}
export const POST = async (req: Request) => {
- console.log('Webhook received');
+ console.log("Webhook received");
const buf = await req.text();
const sig = req.headers.get("Stripe-Signature") as string;
- const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;
+ const webhookSecret = serverEnv.STRIPE_WEBHOOK_SECRET;
let event: Stripe.Event;
-
+
try {
if (!sig || !webhookSecret) {
console.log("❌ Missing webhook secret or signature");
- return new Response("Missing webhook secret or signature", { status: 400 });
+ return new Response("Missing webhook secret or signature", {
+ status: 400,
+ });
}
event = stripe.webhooks.constructEvent(buf, sig, webhookSecret);
console.log(`✅ Event received: ${event.type}`);
@@ -94,26 +108,26 @@ export const POST = async (req: Request) => {
if (relevantEvents.has(event.type)) {
try {
if (event.type === "checkout.session.completed") {
- console.log('Processing checkout.session.completed event');
+ console.log("Processing checkout.session.completed event");
const session = event.data.object as Stripe.Checkout.Session;
- console.log('Session data:', {
+ console.log("Session data:", {
id: session.id,
customerId: session.customer,
- subscriptionId: session.subscription
+ subscriptionId: session.subscription,
});
const customer = await stripe.customers.retrieve(
session.customer as string
);
- console.log('Retrieved customer:', {
+ console.log("Retrieved customer:", {
id: customer.id,
- email: 'email' in customer ? customer.email : undefined,
- metadata: 'metadata' in customer ? customer.metadata : undefined
+ email: "email" in customer ? customer.email : undefined,
+ metadata: "metadata" in customer ? customer.metadata : undefined,
});
-
+
let foundUserId;
let customerEmail;
-
+
if ("metadata" in customer) {
foundUserId = customer.metadata.userId;
}
@@ -121,13 +135,21 @@ export const POST = async (req: Request) => {
customerEmail = customer.email;
}
- console.log("Starting user lookup with:", { foundUserId, customerEmail });
-
+ console.log("Starting user lookup with:", {
+ foundUserId,
+ customerEmail,
+ });
+
// Try to find user with retries
- const dbUser = await findUserWithRetry(customerEmail as string, foundUserId);
-
+ const dbUser = await findUserWithRetry(
+ customerEmail as string,
+ foundUserId
+ );
+
if (!dbUser) {
- console.log("No user found after all retries. Returning 202 to allow retry.");
+ console.log(
+ "No user found after all retries. Returning 202 to allow retry."
+ );
return new Response("User not found, webhook will be retried", {
status: 202,
});
@@ -136,15 +158,15 @@ export const POST = async (req: Request) => {
console.log("Successfully found user:", {
userId: dbUser.id,
email: dbUser.email,
- name: dbUser.name
+ name: dbUser.name,
});
const subscription = await stripe.subscriptions.retrieve(
session.subscription as string
);
- console.log('Retrieved subscription:', {
+ console.log("Retrieved subscription:", {
id: subscription.id,
- status: subscription.status
+ status: subscription.status,
});
const inviteQuota = subscription.items.data.reduce(
@@ -152,11 +174,11 @@ export const POST = async (req: Request) => {
0
);
- console.log('Updating user in database with:', {
+ console.log("Updating user in database with:", {
subscriptionId: session.subscription,
status: subscription.status,
customerId: customer.id,
- inviteQuota
+ inviteQuota,
});
await db
@@ -168,31 +190,31 @@ export const POST = async (req: Request) => {
inviteQuota: inviteQuota,
})
.where(eq(users.id, dbUser.id));
-
+
console.log("Successfully updated user in database");
}
if (event.type === "customer.subscription.updated") {
- console.log('Processing customer.subscription.updated event');
+ console.log("Processing customer.subscription.updated event");
const subscription = event.data.object as Stripe.Subscription;
- console.log('Subscription data:', {
+ console.log("Subscription data:", {
id: subscription.id,
status: subscription.status,
- customerId: subscription.customer
+ customerId: subscription.customer,
});
const customer = await stripe.customers.retrieve(
subscription.customer as string
);
- console.log('Retrieved customer:', {
+ console.log("Retrieved customer:", {
id: customer.id,
- email: 'email' in customer ? customer.email : undefined,
- metadata: 'metadata' in customer ? customer.metadata : undefined
+ email: "email" in customer ? customer.email : undefined,
+ metadata: "metadata" in customer ? customer.metadata : undefined,
});
let foundUserId;
let customerEmail;
-
+
if ("metadata" in customer) {
foundUserId = customer.metadata.userId;
}
@@ -200,13 +222,21 @@ export const POST = async (req: Request) => {
customerEmail = customer.email;
}
- console.log("Starting user lookup with:", { foundUserId, customerEmail });
-
+ console.log("Starting user lookup with:", {
+ foundUserId,
+ customerEmail,
+ });
+
// Try to find user with retries
- const dbUser = await findUserWithRetry(customerEmail as string, foundUserId);
-
+ const dbUser = await findUserWithRetry(
+ customerEmail as string,
+ foundUserId
+ );
+
if (!dbUser) {
- console.log("No user found after all retries. Returning 202 to allow retry.");
+ console.log(
+ "No user found after all retries. Returning 202 to allow retry."
+ );
return new Response("User not found, webhook will be retried", {
status: 202,
});
@@ -215,32 +245,35 @@ export const POST = async (req: Request) => {
console.log("Successfully found user:", {
userId: dbUser.id,
email: dbUser.email,
- name: dbUser.name
+ name: dbUser.name,
});
// Get all active subscriptions for this customer
const subscriptions = await stripe.subscriptions.list({
customer: customer.id,
- status: 'active',
+ status: "active",
});
- console.log('Retrieved all active subscriptions:', {
- count: subscriptions.data.length
+ console.log("Retrieved all active subscriptions:", {
+ count: subscriptions.data.length,
});
// Calculate total invite quota based on all active subscriptions
const inviteQuota = subscriptions.data.reduce((total, sub) => {
- return total + sub.items.data.reduce(
- (subTotal, item) => subTotal + (item.quantity || 1),
- 0
+ return (
+ total +
+ sub.items.data.reduce(
+ (subTotal, item) => subTotal + (item.quantity || 1),
+ 0
+ )
);
}, 0);
- console.log('Updating user in database with:', {
+ console.log("Updating user in database with:", {
subscriptionId: subscription.id,
status: subscription.status,
customerId: customer.id,
- inviteQuota
+ inviteQuota,
});
await db
@@ -252,8 +285,11 @@ export const POST = async (req: Request) => {
inviteQuota: inviteQuota,
})
.where(eq(users.id, dbUser.id));
-
- console.log("Successfully updated user in database with new invite quota:", inviteQuota);
+
+ console.log(
+ "Successfully updated user in database with new invite quota:",
+ inviteQuota
+ );
}
if (event.type === "customer.subscription.deleted") {
@@ -313,8 +349,11 @@ export const POST = async (req: Request) => {
inviteQuota: 1, // Reset to default quota
})
.where(eq(users.id, foundUserId));
-
- console.log("User updated successfully", { foundUserId, inviteQuota: 1 });
+
+ console.log("User updated successfully", {
+ foundUserId,
+ inviteQuota: 1,
+ });
}
return NextResponse.json({ received: true });
diff --git a/apps/web/app/blog/[slug]/page.tsx b/apps/web/app/blog/[slug]/page.tsx
index eebd243cd..129021670 100644
--- a/apps/web/app/blog/[slug]/page.tsx
+++ b/apps/web/app/blog/[slug]/page.tsx
@@ -7,6 +7,7 @@ import type { Metadata } from "next";
import { Share } from "../_components/Share";
import { ReadyToGetStarted } from "@/components/ReadyToGetStarted";
import { calculateReadingTime } from "@/utils/readTime";
+import { clientEnv } from "@cap/env";
interface PostProps {
params: {
@@ -23,7 +24,7 @@ export async function generateMetadata({
}
let { title, publishedAt: publishedTime, description, image } = post.metadata;
- let ogImage = `${process.env.NEXT_PUBLIC_WEB_URL}${image}`;
+ let ogImage = `${clientEnv.NEXT_PUBLIC_WEB_URL}${image}`;
return {
title,
@@ -33,7 +34,7 @@ export async function generateMetadata({
description,
type: "article",
publishedTime,
- url: `${process.env.NEXT_PUBLIC_WEB_URL}/blog/${post.slug}`,
+ url: `${clientEnv.NEXT_PUBLIC_WEB_URL}/blog/${post.slug}`,
images: [
{
url: ogImage,
diff --git a/apps/web/app/blog/_components/Share.tsx b/apps/web/app/blog/_components/Share.tsx
index a20768579..83c5580ed 100644
--- a/apps/web/app/blog/_components/Share.tsx
+++ b/apps/web/app/blog/_components/Share.tsx
@@ -2,6 +2,7 @@
import toast from "react-hot-toast";
import { useState } from "react";
+import { clientEnv } from "@cap/env";
interface ShareProps {
post: {
@@ -13,7 +14,7 @@ interface ShareProps {
}
export function Share({ post }: ShareProps) {
- const shareUrl = `${process.env.NEXT_PUBLIC_WEB_URL}/blog/${post.slug}`;
+ const shareUrl = `${clientEnv.NEXT_PUBLIC_WEB_URL}/blog/${post.slug}`;
const [copied, setCopied] = useState(false);
return (
diff --git a/apps/web/app/dashboard/caps/components/CapCard.tsx b/apps/web/app/dashboard/caps/components/CapCard.tsx
index d862d28e7..9644c8783 100644
--- a/apps/web/app/dashboard/caps/components/CapCard.tsx
+++ b/apps/web/app/dashboard/caps/components/CapCard.tsx
@@ -8,6 +8,7 @@ import { Tooltip } from "react-tooltip";
import { ShareIcon, ChevronDown } from "lucide-react";
import { SharingDialog } from "@/app/dashboard/caps/components/SharingDialog";
import { useRouter } from "next/navigation"; // Add this import
+import { serverEnv, clientEnv, NODE_ENV } from "@cap/env";
interface CapCardProps {
cap: {
@@ -46,7 +47,7 @@ export const CapCard: React.FC<CapCardProps> = ({
}
const response = await fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/video/title`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/video/title`,
{
method: "PUT",
headers: { "Content-Type": "application/json" },
@@ -120,10 +121,9 @@ export const CapCard: React.FC<CapCardProps> = ({
<a
className="group block"
href={
- process.env.NEXT_PUBLIC_IS_CAP &&
- process.env.NEXT_ENV === "production"
+ clientEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production"
? `https://cap.link/${cap.id}`
- : `${process.env.NEXT_PUBLIC_WEB_URL}/s/${cap.id}`
+ : `${clientEnv.NEXT_PUBLIC_WEB_URL}/s/${cap.id}`
}
>
<VideoThumbnail
diff --git a/apps/web/app/dashboard/caps/components/CapCardActions.tsx b/apps/web/app/dashboard/caps/components/CapCardActions.tsx
index 13aef8928..5a0246544 100644
--- a/apps/web/app/dashboard/caps/components/CapCardActions.tsx
+++ b/apps/web/app/dashboard/caps/components/CapCardActions.tsx
@@ -1,3 +1,4 @@
+import { serverEnv, clientEnv, NODE_ENV } from "@cap/env";
import { LinkIcon, Trash } from "lucide-react";
import { toast } from "react-hot-toast";
import { Tooltip } from "react-tooltip";
@@ -13,9 +14,9 @@ export const CapCardActions: React.FC<CapCardActionsProps> = ({
}) => {
const copyLink = () => {
const link =
- process.env.NEXT_PUBLIC_IS_CAP && process.env.NEXT_ENV === "production"
+ clientEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production"
? `https://cap.link/${capId}`
- : `${process.env.NEXT_PUBLIC_WEB_URL}/s/${capId}`;
+ : `${clientEnv.NEXT_PUBLIC_WEB_URL}/s/${capId}`;
navigator.clipboard.writeText(link);
toast.success("Link copied to clipboard!");
diff --git a/apps/web/app/dashboard/caps/components/CapPagination.tsx b/apps/web/app/dashboard/caps/components/CapPagination.tsx
index f5fa413ba..50d17245d 100644
--- a/apps/web/app/dashboard/caps/components/CapPagination.tsx
+++ b/apps/web/app/dashboard/caps/components/CapPagination.tsx
@@ -7,6 +7,7 @@ import {
PaginationNext,
PaginationPrevious,
} from "@cap/ui";
+import { clientEnv } from "@cap/env";
interface CapPaginationProps {
currentPage: number;
@@ -23,7 +24,7 @@ export const CapPagination: React.FC<CapPaginationProps> = ({
{currentPage > 1 && (
<PaginationItem>
<PaginationPrevious
- href={`${process.env.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=${
+ href={`${clientEnv.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=${
currentPage - 1
}`}
/>
@@ -31,7 +32,7 @@ export const CapPagination: React.FC<CapPaginationProps> = ({
)}
<PaginationItem>
<PaginationLink
- href={`${process.env.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=1`}
+ href={`${clientEnv.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=1`}
isActive={currentPage === 1}
>
1
@@ -40,7 +41,7 @@ export const CapPagination: React.FC<CapPaginationProps> = ({
{currentPage !== 1 && (
<PaginationItem>
<PaginationLink
- href={`${process.env.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=${currentPage}`}
+ href={`${clientEnv.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=${currentPage}`}
isActive={true}
>
{currentPage}
@@ -50,7 +51,7 @@ export const CapPagination: React.FC<CapPaginationProps> = ({
{totalPages > currentPage + 1 && (
<PaginationItem>
<PaginationLink
- href={`${process.env.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=${
+ href={`${clientEnv.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=${
currentPage + 1
}`}
isActive={false}
@@ -62,7 +63,7 @@ export const CapPagination: React.FC<CapPaginationProps> = ({
{currentPage > 2 && <PaginationEllipsis />}
<PaginationItem>
<PaginationNext
- href={`${process.env.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=${
+ href={`${clientEnv.NEXT_PUBLIC_WEB_URL}/dashboard/caps?page=${
currentPage === totalPages ? currentPage : currentPage + 1
}`}
/>
diff --git a/apps/web/app/dashboard/shared-caps/components/SharedCapCard.tsx b/apps/web/app/dashboard/shared-caps/components/SharedCapCard.tsx
index fd4610d6f..53ed6ae21 100644
--- a/apps/web/app/dashboard/shared-caps/components/SharedCapCard.tsx
+++ b/apps/web/app/dashboard/shared-caps/components/SharedCapCard.tsx
@@ -3,6 +3,7 @@ import { VideoThumbnail } from "@/components/VideoThumbnail";
import { CapCardAnalytics } from "@/app/dashboard/caps/components/CapCardAnalytics";
import moment from "moment";
import { Tooltip } from "react-tooltip";
+import { serverEnv, clientEnv, NODE_ENV } from "@cap/env";
interface SharedCapCardProps {
cap: {
@@ -39,10 +40,9 @@ export const SharedCapCard: React.FC<SharedCapCardProps> = ({
<a
className="group block"
href={
- process.env.NEXT_PUBLIC_IS_CAP &&
- process.env.NEXT_ENV === "production"
+ clientEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production"
? `https://cap.link/${cap.id}`
- : `${process.env.NEXT_PUBLIC_WEB_URL}/s/${cap.id}`
+ : `${clientEnv.NEXT_PUBLIC_WEB_URL}/s/${cap.id}`
}
>
<VideoThumbnail
diff --git a/apps/web/app/docs/[...slug]/page.tsx b/apps/web/app/docs/[...slug]/page.tsx
index 54e6b26f8..b44c0c932 100644
--- a/apps/web/app/docs/[...slug]/page.tsx
+++ b/apps/web/app/docs/[...slug]/page.tsx
@@ -5,6 +5,7 @@ import { MDXRemote } from "next-mdx-remote/rsc";
import { getDocs } from "@/utils/blog";
import type { Metadata } from "next";
import type { DocMetadata } from "@/utils/blog";
+import { clientEnv } from "@cap/env";
type Doc = {
metadata: DocMetadata;
@@ -49,7 +50,7 @@ export async function generateMetadata(
const { title, summary, image } = doc.metadata;
const ogImage = image
- ? `${process.env.NEXT_PUBLIC_WEB_URL}${image}`
+ ? `${clientEnv.NEXT_PUBLIC_WEB_URL}${image}`
: undefined;
const description = summary || title;
@@ -60,7 +61,7 @@ export async function generateMetadata(
title,
description,
type: "article",
- url: `${process.env.NEXT_PUBLIC_WEB_URL}/docs/${fullSlug}`,
+ url: `${clientEnv.NEXT_PUBLIC_WEB_URL}/docs/${fullSlug}`,
...(ogImage && {
images: [{ url: ogImage }],
}),
diff --git a/apps/web/app/docs/[slug]/page.tsx b/apps/web/app/docs/[slug]/page.tsx
index 2a51048a0..279700a83 100644
--- a/apps/web/app/docs/[slug]/page.tsx
+++ b/apps/web/app/docs/[slug]/page.tsx
@@ -3,6 +3,7 @@ import Image from "next/image";
import { MDXRemote } from "next-mdx-remote/rsc";
import { getDocs } from "@/utils/blog";
import type { Metadata } from "next";
+import { clientEnv } from "@cap/env";
interface DocProps {
params: {
@@ -19,9 +20,7 @@ export async function generateMetadata({
}
let { title, summary: description, image } = doc.metadata;
- let ogImage = image
- ? `${process.env.NEXT_PUBLIC_WEB_URL}${image}`
- : undefined;
+ let ogImage = image ? `${clientEnv.NEXT_PUBLIC_WEB_URL}${image}` : undefined;
return {
title,
@@ -30,7 +29,7 @@ export async function generateMetadata({
title,
description,
type: "article",
- url: `${process.env.NEXT_PUBLIC_WEB_URL}/docs/${doc.slug}`,
+ url: `${clientEnv.NEXT_PUBLIC_WEB_URL}/docs/${doc.slug}`,
...(ogImage && {
images: [
{
diff --git a/apps/web/app/login/form.tsx b/apps/web/app/login/form.tsx
index 7441d091c..30b4eddeb 100644
--- a/apps/web/app/login/form.tsx
+++ b/apps/web/app/login/form.tsx
@@ -6,6 +6,7 @@ import { useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import { toast } from "react-hot-toast";
import { Input, Label } from "@cap/ui";
+import { NODE_ENV } from "@cap/env";
export function LoginForm() {
const searchParams = useSearchParams();
@@ -207,7 +208,7 @@ export function LoginForm() {
}}
className="block w-full appearance-none rounded-full border border-gray-300 px-3 h-12 placeholder-gray-400 shadow-sm focus:border-black focus:outline-none focus:ring-black text-lg"
/>
- {process.env.NODE_ENV === "development" && (
+ {NODE_ENV === "development" && (
<div className="py-3 px-6 flex items-center justify-center bg-red-600 rounded-xl mt-3">
<p className="text-white text-lg">
<span className="font-bold text-white">
@@ -226,7 +227,7 @@ export function LoginForm() {
disabled={loading || emailSent}
>
{emailSent
- ? process.env.NODE_ENV === "development"
+ ? NODE_ENV === "development"
? "Email sent to your terminal"
: "Email sent to your inbox"
: "Continue with Email"}
diff --git a/apps/web/app/providers.tsx b/apps/web/app/providers.tsx
index 858756926..7d2908ae4 100644
--- a/apps/web/app/providers.tsx
+++ b/apps/web/app/providers.tsx
@@ -1,12 +1,13 @@
"use client";
+import { clientEnv } from "@cap/env";
import posthog from "posthog-js";
import { PostHogProvider } from "posthog-js/react";
import { ReactNode } from "react";
if (typeof window !== "undefined") {
- posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY as string, {
- api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST as string,
+ posthog.init(clientEnv.NEXT_PUBLIC_POSTHOG_KEY as string, {
+ api_host: clientEnv.NEXT_PUBLIC_POSTHOG_HOST as string,
});
}
export function CSPostHogProvider({ children }: { children: ReactNode }) {
diff --git a/apps/web/app/s/[videoId]/Share.tsx b/apps/web/app/s/[videoId]/Share.tsx
index 7e9221328..8465a8d2e 100644
--- a/apps/web/app/s/[videoId]/Share.tsx
+++ b/apps/web/app/s/[videoId]/Share.tsx
@@ -8,6 +8,7 @@ import { Toolbar } from "./_components/Toolbar";
import { Logo } from "@cap/ui";
import { Sidebar } from "./_components/Sidebar";
import { useEffect, useState, useRef } from "react";
+import { clientEnv } from "@cap/env";
type CommentWithAuthor = typeof commentsSchema.$inferSelect & {
authorName: string | null;
@@ -132,7 +133,7 @@ export const Share: React.FC<ShareProps> = ({
<div className="mt-auto py-4">
<a
target="_blank"
- href={`${process.env.NEXT_PUBLIC_WEB_URL}?ref=video_${data.id}`}
+ href={`${clientEnv.NEXT_PUBLIC_WEB_URL}?ref=video_${data.id}`}
className="flex items-center justify-center space-x-2 py-2 px-4 bg-gray-100 new-card-style rounded-full mx-auto w-fit"
>
<span className="text-sm">Recorded with</span>
diff --git a/apps/web/app/s/[videoId]/_components/AuthOverlay.tsx b/apps/web/app/s/[videoId]/_components/AuthOverlay.tsx
index 2d13c4b02..50dfcb71c 100644
--- a/apps/web/app/s/[videoId]/_components/AuthOverlay.tsx
+++ b/apps/web/app/s/[videoId]/_components/AuthOverlay.tsx
@@ -1,4 +1,5 @@
import { Dialog, DialogContent, LogoBadge, Button } from "@cap/ui";
+import { NODE_ENV } from "@cap/env";
import { motion } from "framer-motion";
import { signIn } from "next-auth/react";
import { useState, useEffect } from "react";
@@ -55,7 +56,7 @@ export const AuthOverlay: React.FC<AuthOverlayProps> = ({
</div>
<div className="flex flex-col space-y-3 fade-in-down animate-delay-2">
- {process.env.NODE_ENV !== "development" && (
+ {NODE_ENV !== "development" && (
<>
<Button
variant="dark"
@@ -142,7 +143,7 @@ export const AuthOverlay: React.FC<AuthOverlayProps> = ({
}}
className="block w-full appearance-none rounded-full border border-gray-300 px-3 h-12 placeholder-gray-400 shadow-sm focus:border-black focus:outline-none focus:ring-black text-lg"
/>
- {process.env.NODE_ENV === "development" && (
+ {NODE_ENV === "development" && (
<div className="py-3 px-6 flex items-center justify-center bg-red-600 rounded-xl mt-3">
<p className="text-white text-lg">
<span className="font-bold text-white">
@@ -161,7 +162,7 @@ export const AuthOverlay: React.FC<AuthOverlayProps> = ({
disabled={loading || emailSent}
>
{emailSent
- ? process.env.NODE_ENV === "development"
+ ? NODE_ENV === "development"
? "Email sent to your terminal"
: "Email sent to your inbox"
: "Continue with Email"}
diff --git a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx
index 388b08122..8157a3746 100644
--- a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx
+++ b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx
@@ -8,6 +8,7 @@ import { toast } from "react-hot-toast";
import { Copy, Loader2 } from "lucide-react";
import JSZip from "jszip";
import { saveAs } from "file-saver";
+import { clientEnv, NODE_ENV } from "@cap/env";
export const ShareHeader = ({
data,
@@ -29,7 +30,7 @@ export const ShareHeader = ({
const handleBlur = async () => {
setIsEditing(false);
const response = await fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/video/title`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/video/title`,
{
method: "PUT",
headers: { "Content-Type": "application/json" },
@@ -144,31 +145,30 @@ export const ShareHeader = ({
className="hover:bg-gray-300"
onClick={() => {
if (
- process.env.NEXT_PUBLIC_IS_CAP &&
- process.env.NODE_ENV === "production"
+ clientEnv.NEXT_PUBLIC_IS_CAP &&
+ NODE_ENV === "production"
) {
navigator.clipboard.writeText(
`https://cap.link/${data.id}`
);
} else {
navigator.clipboard.writeText(
- `${process.env.NEXT_PUBLIC_WEB_URL}/s/${data.id}`
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/s/${data.id}`
);
}
toast.success("Link copied to clipboard!");
}}
>
- {process.env.NEXT_PUBLIC_IS_CAP &&
- process.env.NODE_ENV === "production"
+ {clientEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production"
? `cap.link/${data.id}`
- : `${process.env.NEXT_PUBLIC_WEB_URL}/s/${data.id}`}
+ : `${clientEnv.NEXT_PUBLIC_WEB_URL}/s/${data.id}`}
<Copy className="ml-2 h-4 w-4" />
</Button>
{user !== null && (
<div className="hidden md:flex">
<Button
onClick={() => {
- push(`${process.env.NEXT_PUBLIC_WEB_URL}/dashboard`);
+ push(`${clientEnv.NEXT_PUBLIC_WEB_URL}/dashboard`);
}}
>
Go to Dashboard
diff --git a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
index 13cf4320f..2e86af4c1 100644
--- a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
+++ b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
@@ -17,6 +17,7 @@ import toast from "react-hot-toast";
import { Tooltip } from "react-tooltip";
import { apiClient } from "@/utils/web-api";
import { S3_BUCKET_URL } from "@cap/utils";
+import { clientEnv, NODE_ENV } from "@cap/env";
declare global {
interface Window {
@@ -388,7 +389,7 @@ export const ShareVideo = forwardRef<
if (
data.bucket &&
- data.awsBucket !== process.env.NEXT_PUBLIC_CAP_AWS_BUCKET
+ data.awsBucket !== clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET
) {
// For custom S3 buckets, fetch through the API
transcriptionUrl = `/api/playlist?userId=${data.ownerId}&videoId=${data.id}&fileType=transcription`;
@@ -465,14 +466,14 @@ export const ShareVideo = forwardRef<
let videoSrc: string;
if (data.source.type === "desktopMP4") {
- videoSrc = `${process.env.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=mp4`;
+ videoSrc = `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=mp4`;
} else if (
// v.cap.so is only available in prod
- process.env.NODE_ENV === "development" ||
+ NODE_ENV === "development" ||
((data.skipProcessing === true || data.jobStatus !== "COMPLETE") &&
data.source.type === "MediaConvert")
) {
- videoSrc = `${process.env.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=master`;
+ videoSrc = `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=master`;
} else if (data.source.type === "MediaConvert") {
videoSrc = `${S3_BUCKET_URL}/${data.ownerId}/${data.id}/output/video_recording_000.m3u8`;
} else {
diff --git a/apps/web/app/s/[videoId]/_components/Toolbar.tsx b/apps/web/app/s/[videoId]/_components/Toolbar.tsx
index 4511176f1..7a981e488 100644
--- a/apps/web/app/s/[videoId]/_components/Toolbar.tsx
+++ b/apps/web/app/s/[videoId]/_components/Toolbar.tsx
@@ -7,6 +7,7 @@ import { useRouter } from "next/navigation";
import { Button } from "@cap/ui";
import toast from "react-hot-toast";
import { AuthOverlay } from "./AuthOverlay";
+import { clientEnv } from "@cap/env";
// million-ignore
export const Toolbar = ({
@@ -83,7 +84,7 @@ export const Toolbar = ({
console.log("Current timestamp:", timestamp);
const response = await fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/video/comment`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/video/comment`,
{
method: "POST",
headers: {
diff --git a/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
index ab25b3d42..824924aad 100644
--- a/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
+++ b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
@@ -4,6 +4,7 @@ import { videos } from "@cap/database/schema";
import { useState, useEffect } from "react";
import { MessageSquare } from "lucide-react";
import { S3_BUCKET_URL } from "@cap/utils";
+import { clientEnv } from "@cap/env";
interface TranscriptProps {
data: typeof videos.$inferSelect;
@@ -124,7 +125,7 @@ export const Transcript: React.FC<TranscriptProps> = ({ data, onSeek }) => {
if (
data.bucket &&
- data.awsBucket !== process.env.NEXT_PUBLIC_CAP_AWS_BUCKET
+ data.awsBucket !== clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET
) {
// For custom S3 buckets, fetch through the API
transcriptionUrl = `/api/playlist?userId=${data.ownerId}&videoId=${data.id}&fileType=transcription`;
@@ -187,7 +188,7 @@ export const Transcript: React.FC<TranscriptProps> = ({ data, onSeek }) => {
// Re-fetch the transcript
const fetchTranscript = async () => {
const transcriptionUrl =
- data.bucket && data.awsBucket !== process.env.NEXT_PUBLIC_CAP_AWS_BUCKET
+ data.bucket && data.awsBucket !== clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET
? `/api/playlist?userId=${data.ownerId}&videoId=${data.id}&fileType=transcription`
: `${S3_BUCKET_URL}/${data.ownerId}/${data.id}/transcription.vtt`;
diff --git a/apps/web/app/s/[videoId]/page.tsx b/apps/web/app/s/[videoId]/page.tsx
index f87c779c1..445b2669a 100644
--- a/apps/web/app/s/[videoId]/page.tsx
+++ b/apps/web/app/s/[videoId]/page.tsx
@@ -13,6 +13,7 @@ import { getCurrentUser, userSelectProps } from "@cap/database/auth/session";
import type { Metadata, ResolvingMetadata } from "next";
import { notFound } from "next/navigation";
import { ImageViewer } from "./_components/ImageViewer";
+import { clientEnv } from "@cap/env";
export const dynamic = "auto";
export const dynamicParams = true;
@@ -73,7 +74,7 @@ export async function generateMetadata(
description: "This video is private and cannot be shared.",
openGraph: {
images: [
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/video/og?videoId=${videoId}`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/video/og?videoId=${videoId}`,
],
},
};
@@ -88,7 +89,7 @@ export async function generateMetadata(
description: "Watch this video on Cap",
openGraph: {
images: [
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/video/og?videoId=${videoId}`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/video/og?videoId=${videoId}`,
],
},
};
@@ -181,7 +182,7 @@ export default async function ShareVideoPage(props: Props) {
) {
console.log("[ShareVideoPage] Creating MUX job for video:", videoId);
const res = await fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/upload/mux/create?videoId=${videoId}&userId=${video.ownerId}`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/upload/mux/create?videoId=${videoId}&userId=${video.ownerId}`,
{
method: "GET",
credentials: "include",
@@ -195,7 +196,7 @@ export default async function ShareVideoPage(props: Props) {
if (video.transcriptionStatus !== "COMPLETE") {
console.log("[ShareVideoPage] Starting transcription for video:", videoId);
fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/video/transcribe?videoId=${videoId}&userId=${video.ownerId}`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/video/transcribe?videoId=${videoId}&userId=${video.ownerId}`,
{
method: "GET",
credentials: "include",
@@ -231,7 +232,7 @@ export default async function ShareVideoPage(props: Props) {
if (video.isScreenshot === true) {
console.log("[ShareVideoPage] Fetching screenshot for video:", videoId);
const res = await fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/screenshot?userId=${video.ownerId}&screenshotId=${videoId}`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/screenshot?userId=${video.ownerId}&screenshotId=${videoId}`,
{
method: "GET",
credentials: "include",
@@ -262,7 +263,7 @@ export default async function ShareVideoPage(props: Props) {
videoId
);
const res = await fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/video/individual?videoId=${videoId}&userId=${video.ownerId}`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/video/individual?videoId=${videoId}&userId=${video.ownerId}`,
{
method: "GET",
credentials: "include",
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index 09c46d46c..f575bf671 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -2,12 +2,6 @@
import("dotenv").then(({ config }) => config({ path: "../../.env" }));
-if (process.env.DB_PLANETSCALE_HOST !== undefined) {
- throw new Error(
- "DB_PLANETSCALE_HOST no longer supported. Use DATABASE_URL instead. Must start with mysql:// for local dev, and https:// for production."
- );
-}
-
import fs from "fs";
import path from "path";
diff --git a/apps/web/package.json b/apps/web/package.json
index 70877962f..ffd9d4e92 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -14,6 +14,7 @@
"@aws-sdk/client-s3": "^3.485.0",
"@aws-sdk/s3-presigned-post": "^3.485.0",
"@aws-sdk/s3-request-presigner": "^3.485.0",
+ "@cap/env": "workspace:*",
"@cap/database": "workspace:*",
"@cap/ui": "workspace:*",
"@cap/utils": "workspace:*",
@@ -29,6 +30,7 @@
"@react-email/components": "^0.0.13",
"@react-email/render": "0.0.11",
"@stripe/stripe-js": "^3.3.0",
+ "@t3-oss/env-nextjs": "^0.12.0",
"@tanstack/react-query": "^5.51.11",
"@tanstack/react-store": "^0.5.5",
"@tanstack/store": "^0.5.5",
@@ -69,7 +71,7 @@
"subtitles-parser-vtt": "^0.1.0",
"tailwind-merge": "^2.1.0",
"video.js": "^8.17.3",
- "zod": "^3.22.4"
+ "zod": "^3.24.1"
},
"devDependencies": {
"@types/file-saver": "^2.0.7",
@@ -87,4 +89,4 @@
"engines": {
"node": "20"
}
-}
\ No newline at end of file
+}
diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json
index 6b2976270..e2d4b4222 100644
--- a/apps/web/tsconfig.json
+++ b/apps/web/tsconfig.json
@@ -11,7 +11,7 @@
"forceConsistentCasingInFileNames": true,
"noUncheckedIndexedAccess": true,
"module": "ESNext",
- "moduleResolution": "Node",
+ "moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
diff --git a/apps/web/utils/cors.ts b/apps/web/utils/cors.ts
index e3459ee72..699de9881 100644
--- a/apps/web/utils/cors.ts
+++ b/apps/web/utils/cors.ts
@@ -1,5 +1,7 @@
+import { clientEnv } from "@cap/env";
+
export const allowedOrigins = [
- process.env.NEXT_PUBLIC_WEB_URL,
+ clientEnv.NEXT_PUBLIC_WEB_URL,
"http://localhost:3001",
"http://localhost:3000",
"tauri://localhost",
diff --git a/apps/web/utils/dub.ts b/apps/web/utils/dub.ts
index 59acf19b9..82517d99a 100644
--- a/apps/web/utils/dub.ts
+++ b/apps/web/utils/dub.ts
@@ -1,5 +1,6 @@
import { Dub } from "dub";
+import { serverEnv } from "@cap/env";
export const dub = new Dub({
- token: process.env.DUB_API_KEY,
+ token: serverEnv.DUB_API_KEY,
});
diff --git a/apps/web/utils/helpers.ts b/apps/web/utils/helpers.ts
index 78dabc8f6..114b76bcd 100644
--- a/apps/web/utils/helpers.ts
+++ b/apps/web/utils/helpers.ts
@@ -2,13 +2,14 @@ import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
import { type NextRequest } from "next/server";
import { ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
+import { clientEnv } from "@cap/env";
export function classNames(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export const allowedOrigins = [
- process.env.NEXT_PUBLIC_WEB_URL,
+ clientEnv.NEXT_PUBLIC_WEB_URL,
"https://cap.link",
"cap.link",
];
diff --git a/apps/web/utils/s3.ts b/apps/web/utils/s3.ts
index f04b8151d..925f13627 100644
--- a/apps/web/utils/s3.ts
+++ b/apps/web/utils/s3.ts
@@ -2,6 +2,7 @@ import { S3Client } from "@aws-sdk/client-s3";
import type { s3Buckets } from "@cap/database/schema";
import type { InferSelectModel } from "drizzle-orm";
import { decrypt } from "@cap/database/crypto";
+import { clientEnv, serverEnv } from "@cap/env";
type S3Config = {
endpoint?: string | null;
@@ -25,11 +26,11 @@ async function tryDecrypt(
export async function getS3Config(config?: S3Config) {
if (!config) {
return {
- endpoint: process.env.NEXT_PUBLIC_CAP_AWS_ENDPOINT,
- region: process.env.NEXT_PUBLIC_CAP_AWS_REGION,
+ endpoint: clientEnv.NEXT_PUBLIC_CAP_AWS_ENDPOINT,
+ region: clientEnv.NEXT_PUBLIC_CAP_AWS_REGION,
credentials: {
- accessKeyId: process.env.CAP_AWS_ACCESS_KEY ?? "",
- secretAccessKey: process.env.CAP_AWS_SECRET_KEY ?? "",
+ accessKeyId: serverEnv.CAP_AWS_ACCESS_KEY ?? "",
+ secretAccessKey: serverEnv.CAP_AWS_SECRET_KEY ?? "",
},
};
}
@@ -37,18 +38,17 @@ export async function getS3Config(config?: S3Config) {
return {
endpoint: config.endpoint
? await tryDecrypt(config.endpoint)
- : process.env.NEXT_PUBLIC_CAP_AWS_ENDPOINT,
+ : clientEnv.NEXT_PUBLIC_CAP_AWS_ENDPOINT,
region:
- (await tryDecrypt(config.region)) ??
- process.env.NEXT_PUBLIC_CAP_AWS_REGION,
+ (await tryDecrypt(config.region)) ?? clientEnv.NEXT_PUBLIC_CAP_AWS_REGION,
credentials: {
accessKeyId:
(await tryDecrypt(config.accessKeyId)) ??
- process.env.CAP_AWS_ACCESS_KEY ??
+ serverEnv.CAP_AWS_ACCESS_KEY ??
"",
secretAccessKey:
(await tryDecrypt(config.secretAccessKey)) ??
- process.env.CAP_AWS_SECRET_KEY ??
+ serverEnv.CAP_AWS_SECRET_KEY ??
"",
},
};
@@ -58,12 +58,12 @@ export async function getS3Bucket(
bucket?: InferSelectModel<typeof s3Buckets> | null
) {
if (!bucket?.bucketName) {
- return process.env.NEXT_PUBLIC_CAP_AWS_BUCKET || "";
+ return clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET || "";
}
return (
((await tryDecrypt(bucket.bucketName)) ??
- process.env.NEXT_PUBLIC_CAP_AWS_BUCKET) ||
+ clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET) ||
""
);
}
diff --git a/apps/web/utils/video/ffmpeg/helpers.ts b/apps/web/utils/video/ffmpeg/helpers.ts
index cc8ca4936..d1b4763ea 100644
--- a/apps/web/utils/video/ffmpeg/helpers.ts
+++ b/apps/web/utils/video/ffmpeg/helpers.ts
@@ -1,5 +1,6 @@
import { S3_BUCKET_URL } from "@cap/utils";
import { FFmpeg } from "@ffmpeg/ffmpeg";
+import { clientEnv } from "@cap/env";
export const playlistToMp4 = async (
userId: string,
@@ -14,7 +15,7 @@ export const playlistToMp4 = async (
}
const videoFetch = await fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/video/playlistUrl?userId=${userId}&videoId=${videoId}`
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/video/playlistUrl?userId=${userId}&videoId=${videoId}`
);
if (videoFetch.status !== 200) {
diff --git a/apps/web/utils/video/upload/helpers.ts b/apps/web/utils/video/upload/helpers.ts
index e6ca9d281..c6dfad8ad 100644
--- a/apps/web/utils/video/upload/helpers.ts
+++ b/apps/web/utils/video/upload/helpers.ts
@@ -1,3 +1,5 @@
+import { clientEnv } from "@cap/env";
+
export async function uploadToS3({
filename,
blobData,
@@ -20,7 +22,7 @@ export async function uploadToS3({
awsRegion: string;
}) {
const response = await fetch(
- `${process.env.NEXT_PUBLIC_WEB_URL}/api/upload/signed`,
+ `${clientEnv.NEXT_PUBLIC_WEB_URL}/api/upload/signed`,
{
method: "POST",
headers: {
diff --git a/apps/web/utils/web-api.ts b/apps/web/utils/web-api.ts
index 126ce89a5..dbeb1a2f2 100644
--- a/apps/web/utils/web-api.ts
+++ b/apps/web/utils/web-api.ts
@@ -1,9 +1,10 @@
import { initClient } from "@ts-rest/core";
import { contract } from "@cap/web-api-contract";
+import { clientEnv } from "@cap/env";
export const apiClient = initClient(contract, {
baseUrl:
typeof window !== "undefined"
- ? `${process.env.NEXT_PUBLIC_WEB_URL}/api`
+ ? `${clientEnv.NEXT_PUBLIC_WEB_URL}/api`
: "/api",
});
diff --git a/packages/config/base.tsconfig.json b/packages/config/base.tsconfig.json
index 825c24576..1b1236d7f 100644
--- a/packages/config/base.tsconfig.json
+++ b/packages/config/base.tsconfig.json
@@ -6,7 +6,7 @@
"skipLibCheck": true,
"esModuleInterop": true,
- "moduleResolution": "node",
+ "moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
diff --git a/packages/database/auth/auth-options.ts b/packages/database/auth/auth-options.ts
index c2069d453..ed9134ef0 100644
--- a/packages/database/auth/auth-options.ts
+++ b/packages/database/auth/auth-options.ts
@@ -9,12 +9,13 @@ import { sendEmail } from "../emails/config";
import { LoginLink } from "../emails/login-link";
import { nanoId } from "../helpers";
import WorkOSProvider from "next-auth/providers/workos";
+import { NODE_ENV, serverEnv } from "@cap/env";
export const config = {
maxDuration: 120,
};
-const secret = process.env.NEXTAUTH_SECRET;
+const secret = serverEnv.NEXTAUTH_SECRET;
export const authOptions: NextAuthOptions = {
adapter: DrizzleAdapter(db),
@@ -28,8 +29,8 @@ export const authOptions: NextAuthOptions = {
},
providers: [
GoogleProvider({
- clientId: process.env.GOOGLE_CLIENT_ID!,
- clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
+ clientId: serverEnv.GOOGLE_CLIENT_ID!,
+ clientSecret: serverEnv.GOOGLE_CLIENT_SECRET!,
authorization: {
params: {
scope: [
@@ -41,8 +42,8 @@ export const authOptions: NextAuthOptions = {
},
}),
WorkOSProvider({
- clientId: process.env.WORKOS_CLIENT_ID as string,
- clientSecret: process.env.WORKOS_API_KEY as string,
+ clientId: serverEnv.WORKOS_CLIENT_ID as string,
+ clientSecret: serverEnv.WORKOS_API_KEY as string,
profile(profile) {
return {
id: profile.id,
@@ -56,8 +57,8 @@ export const authOptions: NextAuthOptions = {
}),
EmailProvider({
sendVerificationRequest({ identifier, url }) {
- console.log({ NODE_ENV: process.env.NODE_ENV });
- if (process.env.NODE_ENV === "development") {
+ console.log({ NODE_ENV });
+ if (NODE_ENV === "development") {
console.log(`Login link: ${url}`);
} else {
sendEmail({
diff --git a/packages/database/auth/drizzle-adapter.ts b/packages/database/auth/drizzle-adapter.ts
index 292b9e3b5..3538997e1 100644
--- a/packages/database/auth/drizzle-adapter.ts
+++ b/packages/database/auth/drizzle-adapter.ts
@@ -3,7 +3,8 @@ import { and, eq } from "drizzle-orm";
import { accounts, sessions, users, verificationTokens } from "../schema";
import type { Adapter } from "next-auth/adapters";
import type { PlanetScaleDatabase } from "drizzle-orm/planetscale-serverless";
-import { stripe } from "@cap/utils";
+import { stripe, STRIPE_AVAILABLE } from "@cap/utils";
+import { serverEnv } from "@cap/env";
export function DrizzleAdapter(db: PlanetScaleDatabase): Adapter {
return {
@@ -24,19 +25,21 @@ export function DrizzleAdapter(db: PlanetScaleDatabase): Adapter {
const row = rows[0];
if (!row) throw new Error("User not found");
- const customer = await stripe.customers.create({
- email: userData.email,
- metadata: {
- userId: nanoId(),
- },
- });
+ if (STRIPE_AVAILABLE) {
+ const customer = await stripe.customers.create({
+ email: userData.email,
+ metadata: {
+ userId: nanoId(),
+ },
+ });
- await db
- .update(users)
- .set({
- stripeCustomerId: customer.id,
- })
- .where(eq(users.id, row.id));
+ await db
+ .update(users)
+ .set({
+ stripeCustomerId: customer.id,
+ })
+ .where(eq(users.id, row.id));
+ }
return row;
},
diff --git a/packages/database/crypto.ts b/packages/database/crypto.ts
index b9aed2826..6aa74cb5d 100644
--- a/packages/database/crypto.ts
+++ b/packages/database/crypto.ts
@@ -1,60 +1,66 @@
-const ALGORITHM = { name: 'AES-GCM', length: 256 };
+import { serverEnv } from "@cap/env";
+
+const ALGORITHM = { name: "AES-GCM", length: 256 };
const IV_LENGTH = 12;
const SALT_LENGTH = 16;
const KEY_LENGTH = 32;
const ITERATIONS = 100000;
-const ENCRYPTION_KEY = process.env.DATABASE_ENCRYPTION_KEY as string;
+const ENCRYPTION_KEY = serverEnv.DATABASE_ENCRYPTION_KEY as string;
// Verify the encryption key is valid hex and correct length
try {
- const keyBuffer = Buffer.from(ENCRYPTION_KEY, 'hex');
+ const keyBuffer = Buffer.from(ENCRYPTION_KEY, "hex");
if (keyBuffer.length !== KEY_LENGTH) {
- throw new Error(`Encryption key must be ${KEY_LENGTH} bytes (${KEY_LENGTH * 2} hex characters)`);
+ throw new Error(
+ `Encryption key must be ${KEY_LENGTH} bytes (${
+ KEY_LENGTH * 2
+ } hex characters)`
+ );
}
} catch (error: unknown) {
if (error instanceof Error) {
throw new Error(`Invalid encryption key format: ${error.message}`);
}
- throw new Error('Invalid encryption key format');
+ throw new Error("Invalid encryption key format");
}
async function deriveKey(salt: Uint8Array): Promise<CryptoKey> {
// Convert hex string to ArrayBuffer for Web Crypto API
- const keyBuffer = Buffer.from(ENCRYPTION_KEY, 'hex');
-
+ const keyBuffer = Buffer.from(ENCRYPTION_KEY, "hex");
+
const keyMaterial = await crypto.subtle.importKey(
- 'raw',
+ "raw",
keyBuffer,
- 'PBKDF2',
+ "PBKDF2",
false,
- ['deriveKey']
+ ["deriveKey"]
);
return crypto.subtle.deriveKey(
{
- name: 'PBKDF2',
+ name: "PBKDF2",
salt,
iterations: ITERATIONS,
- hash: 'SHA-256',
+ hash: "SHA-256",
},
keyMaterial,
ALGORITHM,
false,
- ['encrypt', 'decrypt']
+ ["encrypt", "decrypt"]
);
}
export async function encrypt(text: string): Promise<string> {
if (!text) {
- throw new Error('Cannot encrypt empty or null text');
+ throw new Error("Cannot encrypt empty or null text");
}
try {
const salt = crypto.getRandomValues(new Uint8Array(SALT_LENGTH));
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH));
const key = await deriveKey(salt);
-
+
const encoded = new TextEncoder().encode(text);
const encrypted = await crypto.subtle.encrypt(
{
@@ -69,26 +75,26 @@ export async function encrypt(text: string): Promise<string> {
const result = Buffer.concat([
Buffer.from(salt),
Buffer.from(iv),
- Buffer.from(encrypted)
+ Buffer.from(encrypted),
]);
-
- return result.toString('base64');
+
+ return result.toString("base64");
} catch (error: unknown) {
if (error instanceof Error) {
throw new Error(`Encryption failed: ${error.message}`);
}
- throw new Error('Encryption failed');
+ throw new Error("Encryption failed");
}
}
export async function decrypt(encryptedText: string): Promise<string> {
if (!encryptedText) {
- throw new Error('Cannot decrypt empty or null text');
+ throw new Error("Cannot decrypt empty or null text");
}
try {
- const encrypted = Buffer.from(encryptedText, 'base64');
-
+ const encrypted = Buffer.from(encryptedText, "base64");
+
// Extract the components
const salt = encrypted.subarray(0, SALT_LENGTH);
const iv = encrypted.subarray(SALT_LENGTH, SALT_LENGTH + IV_LENGTH);
@@ -96,7 +102,7 @@ export async function decrypt(encryptedText: string): Promise<string> {
// Derive the same key using the extracted salt
const key = await deriveKey(salt);
-
+
const decrypted = await crypto.subtle.decrypt(
{
name: ALGORITHM.name,
@@ -111,6 +117,6 @@ export async function decrypt(encryptedText: string): Promise<string> {
if (error instanceof Error) {
throw new Error(`Decryption failed: ${error.message}`);
}
- throw new Error('Decryption failed');
+ throw new Error("Decryption failed");
}
-}
\ No newline at end of file
+}
diff --git a/packages/database/drizzle.config.ts b/packages/database/drizzle.config.ts
index e9fc28deb..dfc8589fb 100644
--- a/packages/database/drizzle.config.ts
+++ b/packages/database/drizzle.config.ts
@@ -1,6 +1,7 @@
+import { serverEnv } from "@cap/env";
import type { Config } from "drizzle-kit";
-const URL = process.env.DATABASE_MIGRATION_URL ?? process.env.DATABASE_URL;
+const URL = serverEnv.DATABASE_MIGRATION_URL ?? serverEnv.DATABASE_URL;
if (!URL)
throw new Error("DATABASE_URL or DATABASE_MIGRATION_URL must be set!");
diff --git a/packages/database/emails/config.ts b/packages/database/emails/config.ts
index 21c778370..96ab4090a 100644
--- a/packages/database/emails/config.ts
+++ b/packages/database/emails/config.ts
@@ -1,8 +1,9 @@
+import { clientEnv, serverEnv } from "@cap/env";
import { JSXElementConstructor, ReactElement } from "react";
import { Resend } from "resend";
-export const resend = process.env.RESEND_API_KEY
- ? new Resend(process.env.RESEND_API_KEY)
+export const resend = serverEnv.RESEND_API_KEY
+ ? new Resend(serverEnv.RESEND_API_KEY)
: null;
export const sendEmail = async ({
@@ -26,9 +27,9 @@ export const sendEmail = async ({
return resend.emails.send({
from: marketing
? "Richie from Cap.so <[email protected]>"
- : process.env.NEXT_PUBLIC_IS_CAP
+ : clientEnv.NEXT_PUBLIC_IS_CAP
? "Cap Auth <[email protected]>"
- : `auth@${process.env.NEXT_PUBLIC_WEB_URL}`,
+ : `auth@${clientEnv.NEXT_PUBLIC_WEB_URL}`,
to: test ? "[email protected]" : email,
subject,
react,
diff --git a/packages/database/index.ts b/packages/database/index.ts
index cbd1941d9..f633f34f9 100644
--- a/packages/database/index.ts
+++ b/packages/database/index.ts
@@ -1,11 +1,12 @@
import { drizzle } from "drizzle-orm/planetscale-serverless";
import { Client, Config } from "@planetscale/database";
+import { NODE_ENV, serverEnv } from "@cap/env";
-const URL = process.env.DATABASE_URL!;
+const URL = serverEnv.DATABASE_URL;
let fetchHandler: Promise<Config["fetch"]> | undefined = undefined;
-if (process.env.NODE_ENV === "development" && URL.startsWith("mysql://")) {
+if (NODE_ENV === "development" && URL.startsWith("mysql://")) {
fetchHandler = import("@mattrax/mysql-planetscale").then((m) =>
m.createFetchHandler(URL)
);
diff --git a/packages/database/package.json b/packages/database/package.json
index e5219766b..8d4affc05 100644
--- a/packages/database/package.json
+++ b/packages/database/package.json
@@ -12,6 +12,7 @@
"db:studio": "drizzle-kit studio --config=drizzle.config.ts"
},
"dependencies": {
+ "@cap/env": "workspace:*",
"@mattrax/mysql-planetscale": "^0.0.3",
"@paralleldrive/cuid2": "^2.2.2",
"@planetscale/database": "^1.13.0",
@@ -42,4 +43,4 @@
"engines": {
"node": "20"
}
-}
\ No newline at end of file
+}
diff --git a/packages/database/tsconfig.json b/packages/database/tsconfig.json
index ddc01410e..0c2367d79 100644
--- a/packages/database/tsconfig.json
+++ b/packages/database/tsconfig.json
@@ -4,6 +4,7 @@
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"baseUrl": ".",
+ "moduleResolution": "bundler",
"paths": {
"@/emails/*": ["./emails/*"]
}
diff --git a/packages/env/client.ts b/packages/env/client.ts
new file mode 100644
index 000000000..1d52b6a7b
--- /dev/null
+++ b/packages/env/client.ts
@@ -0,0 +1,27 @@
+import { createEnv } from "@t3-oss/env-nextjs";
+import { z } from "zod";
+
+export const NODE_ENV = process.env.NODE_ENV as string;
+
+export const clientEnv = createEnv({
+ client: {
+ NEXT_PUBLIC_WEB_URL: z.string(),
+ NEXT_PUBLIC_CAP_AWS_BUCKET: z.string(),
+ NEXT_PUBLIC_CAP_AWS_REGION: z.string(),
+ NEXT_PUBLIC_CAP_AWS_ENDPOINT: z.string().optional(),
+ NEXT_PUBLIC_CAP_AWS_BUCKET_URL: z.string().optional(),
+ NEXT_PUBLIC_IS_CAP: z.string().optional(),
+ NEXT_PUBLIC_POSTHOG_KEY: z.string().optional(),
+ NEXT_PUBLIC_POSTHOG_HOST: z.string().optional(),
+ },
+ runtimeEnv: {
+ NEXT_PUBLIC_WEB_URL: process.env.NEXT_PUBLIC_WEB_URL,
+ NEXT_PUBLIC_CAP_AWS_BUCKET: process.env.NEXT_PUBLIC_CAP_AWS_BUCKET,
+ NEXT_PUBLIC_CAP_AWS_REGION: process.env.NEXT_PUBLIC_CAP_AWS_REGION,
+ NEXT_PUBLIC_CAP_AWS_ENDPOINT: process.env.NEXT_PUBLIC_CAP_AWS_ENDPOINT,
+ NEXT_PUBLIC_CAP_AWS_BUCKET_URL: process.env.NEXT_PUBLIC_CAP_AWS_BUCKET_URL,
+ NEXT_PUBLIC_IS_CAP: process.env.NEXT_PUBLIC_IS_CAP,
+ NEXT_PUBLIC_POSTHOG_KEY: process.env.NEXT_PUBLIC_POSTHOG_KEY,
+ NEXT_PUBLIC_POSTHOG_HOST: process.env.NEXT_PUBLIC_POSTHOG_HOST,
+ },
+});
diff --git a/packages/env/index.ts b/packages/env/index.ts
new file mode 100644
index 000000000..40db60cf6
--- /dev/null
+++ b/packages/env/index.ts
@@ -0,0 +1,2 @@
+export { clientEnv, NODE_ENV } from "./client";
+export { serverEnv } from "./server";
diff --git a/packages/env/package.json b/packages/env/package.json
new file mode 100644
index 000000000..ee1a61866
--- /dev/null
+++ b/packages/env/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "@cap/env",
+ "private": true,
+ "main": "./index.ts",
+ "types": "./index.ts",
+ "dependencies": {
+ "@t3-oss/env-nextjs": "^0.12.0",
+ "zod": "^3.24.1"
+ },
+ "devDependencies": {
+ "@types/node": "^22.12.0"
+ }
+}
diff --git a/packages/env/server.ts b/packages/env/server.ts
new file mode 100644
index 000000000..552f45fa9
--- /dev/null
+++ b/packages/env/server.ts
@@ -0,0 +1,30 @@
+import { createEnv } from "@t3-oss/env-nextjs";
+import { z } from "zod";
+
+export const serverEnv = createEnv({
+ server: {
+ NODE_ENV: z.string(),
+ DATABASE_URL: z.string(),
+ DATABASE_MIGRATION_URL: z.string().optional(),
+ DATABASE_ENCRYPTION_KEY: z.string().optional(),
+ CAP_AWS_ACCESS_KEY: z.string(),
+ CAP_AWS_SECRET_KEY: z.string(),
+ CAP_AWS_MEDIACONVERT_ROLE_ARN: z.string().optional(),
+ CAP_CLOUDFRONT_DISTRIBUTION_ID: z.string().optional(),
+ NEXTAUTH_SECRET: z.string(),
+ NEXTAUTH_URL: z.string(),
+ GOOGLE_CLIENT_ID: z.string().optional(),
+ GOOGLE_CLIENT_SECRET: z.string().optional(),
+ WORKOS_CLIENT_ID: z.string().optional(),
+ WORKOS_API_KEY: z.string().optional(),
+ DUB_API_KEY: z.string().optional(),
+ RESEND_API_KEY: z.string().optional(),
+ DEEPGRAM_API_KEY: z.string().optional(),
+ NEXT_LOOPS_KEY: z.string().optional(),
+ STRIPE_SECRET_KEY_TEST: z.string().optional(),
+ STRIPE_SECRET_KEY_LIVE: z.string().optional(),
+ STRIPE_WEBHOOK_SECRET: z.string().optional(),
+ DISCORD_FEEDBACK_WEBHOOK_URL: z.string().optional(),
+ },
+ experimental__runtimeEnv: process.env,
+});
diff --git a/packages/env/tsconfig.json b/packages/env/tsconfig.json
new file mode 100644
index 000000000..980872899
--- /dev/null
+++ b/packages/env/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "../config/base.tsconfig.json",
+ "exclude": ["node_modules"],
+ "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
+ "compilerOptions": {
+ "baseUrl": ".",
+ "moduleResolution": "bundler"
+ }
+}
diff --git a/packages/utils/package.json b/packages/utils/package.json
index 190dd2b89..6a74f4cb3 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -20,6 +20,7 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.485.0",
+ "@cap/env": "workspace:*",
"clsx": "^2.0.0",
"stripe": "^14.24.0",
"tailwind-merge": "^2.1.0"
diff --git a/packages/utils/src/constants/plans.ts b/packages/utils/src/constants/plans.ts
index 31b797f2b..c74f5724d 100644
--- a/packages/utils/src/constants/plans.ts
+++ b/packages/utils/src/constants/plans.ts
@@ -1,3 +1,5 @@
+import { NODE_ENV } from "@cap/env";
+
const planIds = {
development: {
yearly: "price_1Q3esrFJxA1XpeSsFwp486RN",
@@ -10,7 +12,7 @@ const planIds = {
};
export const getProPlanId = (billingCycle: "yearly" | "monthly") => {
- const value = process.env.NODE_ENV;
+ const value = NODE_ENV;
const environment = value === "development" ? "development" : "production";
return planIds[environment]?.[billingCycle] || "";
diff --git a/packages/utils/src/constants/s3.ts b/packages/utils/src/constants/s3.ts
index 16fe85dc6..bca3a93e6 100644
--- a/packages/utils/src/constants/s3.ts
+++ b/packages/utils/src/constants/s3.ts
@@ -1,8 +1,10 @@
+import { clientEnv } from "@cap/env";
+
export const S3_BUCKET_URL = (() => {
- const fixedUrl = process.env.NEXT_PUBLIC_CAP_AWS_BUCKET_URL;
- const endpoint = process.env.NEXT_PUBLIC_CAP_AWS_ENDPOINT;
- const bucket = process.env.NEXT_PUBLIC_CAP_AWS_BUCKET;
- const region = process.env.NEXT_PUBLIC_CAP_AWS_REGION;
+ const fixedUrl = clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET_URL;
+ const endpoint = clientEnv.NEXT_PUBLIC_CAP_AWS_ENDPOINT;
+ const bucket = clientEnv.NEXT_PUBLIC_CAP_AWS_BUCKET;
+ const region = clientEnv.NEXT_PUBLIC_CAP_AWS_REGION;
if (fixedUrl) return fixedUrl;
if (endpoint) return `${endpoint}/${bucket}`;
diff --git a/packages/utils/src/lib/stripe/stripe.ts b/packages/utils/src/lib/stripe/stripe.ts
index 99a04a4b0..24e9f68ea 100644
--- a/packages/utils/src/lib/stripe/stripe.ts
+++ b/packages/utils/src/lib/stripe/stripe.ts
@@ -1,14 +1,13 @@
+import { serverEnv } from "@cap/env";
import Stripe from "stripe";
-export const stripe = new Stripe(
- process.env.STRIPE_SECRET_KEY_TEST ??
- process.env.STRIPE_SECRET_KEY_LIVE ??
- "",
- {
- apiVersion: "2023-10-16",
- appInfo: {
- name: "Cap",
- version: "0.1.0",
- },
- }
-);
+const key =
+ serverEnv.STRIPE_SECRET_KEY_TEST ?? serverEnv.STRIPE_SECRET_KEY_LIVE ?? "";
+export const STRIPE_AVAILABLE = key !== "";
+export const stripe = new Stripe(key, {
+ apiVersion: "2023-10-16",
+ appInfo: {
+ name: "Cap",
+ version: "0.1.0",
+ },
+});
diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json
index 8b7dc0b9c..a74c980bc 100644
--- a/packages/utils/tsconfig.json
+++ b/packages/utils/tsconfig.json
@@ -5,6 +5,7 @@
"compilerOptions": {
"rootDir": "src",
"baseUrl": ".",
+ "moduleResolution": "bundler",
"paths": {
"@/*": ["./src/*"]
}
diff --git a/packages/web-api-contract/package.json b/packages/web-api-contract/package.json
index c2ac51450..093ad0ee0 100644
--- a/packages/web-api-contract/package.json
+++ b/packages/web-api-contract/package.json
@@ -6,6 +6,6 @@
"type": "module",
"dependencies": {
"@ts-rest/core": "^3.51.0",
- "zod": "^3.22.4"
+ "zod": "^3.24.1"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index cb2b34abf..03376b78e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -15,7 +15,7 @@ importers:
devDependencies:
'@turbo/gen':
specifier: ^1.9.7
- version: 1.13.4(@types/[email protected])([email protected])
+ version: 1.13.4(@types/[email protected])([email protected])
dotenv-cli:
specifier: latest
version: 8.0.0
@@ -102,7 +102,7 @@ importers:
version: 0.14.7([email protected])
'@solidjs/start':
specifier: ^1.0.6
'@tanstack/solid-query':
specifier: ^5.51.21
version: 5.56.2([email protected])
@@ -144,7 +144,7 @@ importers:
version: 2.0.0
'@ts-rest/core':
specifier: ^3.51.0
- version: 3.51.0(@types/[email protected])([email protected])
+ version: 3.51.0(@types/[email protected])([email protected])
'@types/react-tooltip':
specifier: ^4.2.4
@@ -180,7 +180,7 @@ importers:
version: 0.19.3
vinxi:
specifier: ^0.4.1
webcodecs:
specifier: ^0.1.0
version: 0.1.0
@@ -208,10 +208,10 @@ importers:
version: 5.7.2
vite:
specifier: ^5.4.3
- version: 5.4.8(@types/[email protected])([email protected])
+ version: 5.4.8(@types/[email protected])([email protected])
vite-tsconfig-paths:
specifier: ^5.0.1
apps/embed:
dependencies:
@@ -285,8 +285,8 @@ importers:
specifier: ^0.1.0
version: 0.1.0
zod:
- specifier: ^3.22.4
- version: 3.23.8
+ specifier: ^3.24.1
+ version: 3.24.1
devDependencies:
'@types/node':
specifier: ^20.11.5
@@ -357,16 +357,16 @@ importers:
storybook-solidjs-vite:
specifier: ^1.0.0-beta.2
typescript:
specifier: ^5.7.2
version: 5.7.2
vite:
specifier: ^5.3.4
- version: 5.4.8(@types/[email protected])([email protected])
+ version: 5.4.8(@types/[email protected])([email protected])
vite-plugin-solid:
specifier: ^2.10.2
apps/tasks:
dependencies:
@@ -467,6 +467,9 @@ importers:
'@cap/database':
specifier: workspace:*
version: link:../../packages/database
+ '@cap/env':
+ specifier: workspace:*
+ version: link:../../packages/env
'@cap/ui':
specifier: workspace:*
version: link:../../packages/ui
@@ -509,6 +512,9 @@ importers:
'@stripe/stripe-js':
specifier: ^3.3.0
version: 3.5.0
+ '@t3-oss/env-nextjs':
+ specifier: ^0.12.0
'@tanstack/react-query':
specifier: ^5.51.11
version: 5.56.2([email protected])
@@ -520,7 +526,7 @@ importers:
version: 0.5.5
'@ts-rest/core':
specifier: ^3.51.0
- version: 3.51.0(@types/[email protected])([email protected])
+ version: 3.51.0(@types/[email protected])([email protected])
'@workos-inc/node':
specifier: ^7.34.0
@@ -544,7 +550,7 @@ importers:
version: 0.30.9(@opentelemetry/[email protected])(@planetscale/[email protected])(@types/[email protected])([email protected])([email protected])
dub:
specifier: ^0.33.1
- version: 0.33.1([email protected])
+ version: 0.33.1([email protected])
file-saver:
specifier: ^2.0.5
version: 2.0.5
@@ -630,8 +636,8 @@ importers:
specifier: ^8.17.3
version: 8.17.4
zod:
- specifier: ^3.22.4
- version: 3.23.8
+ specifier: ^3.24.1
+ version: 3.24.1
devDependencies:
'@types/file-saver':
specifier: ^2.0.7
@@ -718,6 +724,9 @@ importers:
packages/database:
dependencies:
+ '@cap/env':
+ specifier: workspace:*
+ version: link:../env
'@mattrax/mysql-planetscale':
specifier: ^0.0.3
version: 0.0.3
@@ -792,6 +801,19 @@ importers:
specifier: ^5.7.2
version: 5.7.2
+ packages/env:
+ dependencies:
+ '@t3-oss/env-nextjs':
+ specifier: ^0.12.0
+ zod:
+ specifier: ^3.24.1
+ version: 3.24.1
+ devDependencies:
+ '@types/node':
+ specifier: ^22.12.0
+ version: 22.12.0
+
packages/local-docker: {}
packages/tsconfig: {}
@@ -918,7 +940,7 @@ importers:
version: 1.9.3
tailwindcss:
specifier: ^3.4.10
devDependencies:
'@fontsource/geist-sans':
specifier: ^5.0.3
@@ -928,10 +950,10 @@ importers:
version: 2.2.253
'@kobalte/tailwindcss':
specifier: ^0.9.0
'@tailwindcss/typography':
specifier: ^0.5.9
autoprefixer:
specifier: ^10.4.20
version: 10.4.20([email protected])
@@ -943,16 +965,16 @@ importers:
tailwind-scrollbar:
specifier: ^3.1.0
tailwindcss-animate:
specifier: ^1.0.6
unplugin-auto-import:
specifier: ^0.18.2
version: 0.18.3([email protected])
unplugin-fonts:
specifier: ^1.1.1
unplugin-icons:
specifier: ^0.19.2
version: 0.19.3
@@ -962,6 +984,9 @@ importers:
'@aws-sdk/client-s3':
specifier: ^3.485.0
version: 3.658.1
+ '@cap/env':
+ specifier: workspace:*
+ version: link:../env
clsx:
specifier: ^2.0.0
version: 2.1.1
@@ -992,10 +1017,10 @@ importers:
dependencies:
'@ts-rest/core':
specifier: ^3.51.0
- version: 3.51.0(@types/[email protected])([email protected])
+ version: 3.51.0(@types/[email protected])([email protected])
zod:
- specifier: ^3.22.4
- version: 3.23.8
+ specifier: ^3.24.1
+ version: 3.24.1
packages:
@@ -4308,10 +4333,10 @@ packages:
react-dom:
optional: true
- '@storybook/[email protected]':
- resolution: {integrity: sha512-O5Ha7ub4dsXSbOo4/yBa9mBGuBp6puJHH47m528KXFiuaj4FgP0OHdD2ztbk3mMGTYl+HM8m8JuByPkBZm0RRg==}
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-NfLTdOSm1oGaxJJ62esQlNXkHxWNuawWPwg0TBeyuNxE7YA9YmMa+07dtTz6WVr7LuDxWl6qq0NBz3s05JpYAA==}
peerDependencies:
- storybook: ^8.6.0-alpha.2
+ storybook: ^8.6.0-alpha.3
vite: ^4.0.0 || ^5.0.0 || ^6.0.0
'@storybook/[email protected]':
@@ -4322,10 +4347,10 @@ packages:
peerDependencies:
storybook: ^8.3.3
- '@storybook/[email protected]':
- resolution: {integrity: sha512-g5XY9SAe5hp8YzjBk6jHORt0Mn6YF4JI1upFFxTa+YjMMgx7R3tERN+rDoAIZcVTCTTqrjG0LhR8KhMVdY4yMA==}
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-uAyRJyec4ydCWrUyzPXyjnJLUI1jbYfSklRW1sEjTIEfRxkPNKNg2XIajGOxeF4GEyvKqArz/4KJU3sFt66w/w==}
peerDependencies:
- storybook: ^8.6.0-alpha.2
+ storybook: ^8.6.0-alpha.3
'@storybook/[email protected]':
resolution: {integrity: sha512-dHYFQH3mA+EtnCkHXzicbLgsvzYjcDJ1JWsogbItZogkPHgSJM/Wr71uMkcvw8v9mmCyP4NpXJuu6bPoVsOnzg==}
@@ -4379,6 +4404,34 @@ packages:
resolution: {integrity: sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==}
+ '@t3-oss/[email protected]':
+ resolution: {integrity: sha512-lOPj8d9nJJTt81mMuN9GMk8x5veOt7q9m11OSnCBJhwp1QrL/qR+M8Y467ULBSm9SunosryWNbmQQbgoiMgcdw==}
+ peerDependencies:
+ typescript: '>=5.0.0'
+ valibot: ^1.0.0-beta.7 || ^1.0.0
+ zod: ^3.24.0
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+ valibot:
+ optional: true
+ zod:
+ optional: true
+
+ '@t3-oss/[email protected]':
+ resolution: {integrity: sha512-rFnvYk1049RnNVUPvY8iQ55AuQh1Rr+qZzQBh3t++RttCGK4COpXGNxS4+45afuQq02lu+QAOy/5955aU8hRKw==}
+ peerDependencies:
+ typescript: '>=5.0.0'
+ valibot: ^1.0.0-beta.7 || ^1.0.0
+ zod: ^3.24.0
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+ valibot:
+ optional: true
+ zod:
+ optional: true
+
'@tailwindcss/[email protected]':
resolution: {integrity: sha512-AqhlCXl+8grUz8uqExv5OTtgpjuVIwFTSXTrh8y9/pw6q2ek7fJ+Y8ZEVw7EB2DCcuCOtEjf9w3+J3rzts01uA==}
peerDependencies:
@@ -4811,6 +4864,9 @@ packages:
resolution: {integrity: sha512-rkvIVJxsOfBejxK7I0FO5sa2WxFmJCzoDwcd88+fq/CUfynNywTo/1/T6hyFz22CyztsnLS9nVlHOnTI36RH5w==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-Fll2FZ1riMjNmlmJOdAyY5pUbkftXslB5DgEzlIuNaiWhXd00FhWxVC/r4yV/4wBb9JfImTu+jiSvXTkJ7F/gA==}
+
resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==}
@@ -6803,6 +6859,10 @@ packages:
resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==}
engines: {node: '>=8.6.0'}
+ resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==}
+ engines: {node: '>=8.6.0'}
+
resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==}
@@ -10473,6 +10533,9 @@ packages:
resolution: {integrity: sha512-jqbIpTsa/KKTJYWgPNsFNbLVpwCgzXfFJ1ukNn4I8hMwyQzHMJnk/BqWzggB0xpkILuKzaO/aMYhS0SkaJyKXg==}
+ resolution: {integrity: sha512-d4IxJUXROL5NCa3amvMg6VQW2HVtZYmUTPfvVtO7zJWGYLJ+mry9v2OmYm+z67aniQoQ8/yFNadiEwtNS9qQiw==}
+
resolution: {integrity: sha512-ulNZP1SVpRDesxeMLON/LtWM8HIgAJEIVpVVhBM6gsmvQ8+Rh+ZG7FWGvHh7Ah3pRABwVJWklWCr/BTZSv0xnQ==}
engines: {node: ^18 || >=20}
@@ -10648,6 +10711,9 @@ packages:
resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==}
+ resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
+
resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==}
engines: {node: '>=14.0'}
@@ -10779,6 +10845,10 @@ packages:
resolution: {integrity: sha512-5liCNPuJW8dqh3+DM6uNM2EI3MLLpCKp/KY+9pB5M2S2SR2qvvDHhKgBOaTWEbZTAws3CXfB0rKTIolWKL05VQ==}
engines: {node: '>=14.0.0'}
+ resolution: {integrity: sha512-4/u/j4FrCKdi17jaxuJA0jClGxB1AvU2hw/IuayPc4ay1XGaJs/rbb4v5WKwAjNifjmXK9PIFyuPiaK8azyR9w==}
+ engines: {node: '>=14.0.0'}
+
resolution: {integrity: sha512-ARZYTXiC+e8z3lRM7/qY9oyaOkaozCeNd2xoz7sYK9fv7OLGhVsf+BZbmASqiK/HTZ7T6eAlnVq9JynZppyk3w==}
peerDependencies:
@@ -11219,8 +11289,8 @@ packages:
engines: {node: '>= 14'}
hasBin: true
- resolution: {integrity: sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==}
+ resolution: {integrity: sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==}
engines: {node: '>= 14'}
hasBin: true
@@ -11251,8 +11321,8 @@ packages:
resolution: {integrity: sha512-zK7YHHz4ZXpW89AHXUPbQVGKI7uvkd3hzusTdotCg1UxyaVtg0zFJSTfW/Dq5f7OBBVnq6cZIaC8Ti4hb6dtCA==}
engines: {node: '>= 14'}
- resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==}
+ resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==}
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
@@ -12194,14 +12264,14 @@ snapshots:
'@contentlayer2/core': 0.5.3([email protected])([email protected])
'@contentlayer2/utils': 0.5.3
chokidar: 3.6.0
- fast-glob: 3.3.2
+ fast-glob: 3.3.3
gray-matter: 4.0.3
imagescript: 1.3.0
micromatch: 4.0.8
- ts-pattern: 5.5.0
+ ts-pattern: 5.6.2
unified: 11.0.5
- yaml: 2.6.1
- zod: 3.23.8
+ yaml: 2.7.0
+ zod: 3.24.1
transitivePeerDependencies:
- '@effect-ts/otel-node'
- acorn
@@ -12831,10 +12901,10 @@ snapshots:
dependencies:
hono: 4.6.3
dependencies:
hono: 4.6.3
- zod: 3.23.8
+ zod: 3.24.1
dependencies:
@@ -13140,6 +13210,10 @@ snapshots:
dependencies:
+ dependencies:
+
dependencies:
'@solid-primitives/event-listener': 2.3.3([email protected])
@@ -14918,11 +14992,11 @@ snapshots:
dependencies:
solid-js: 1.9.3
dependencies:
defu: 6.1.4
error-stack-parser: 2.1.4
glob: 10.4.5
@@ -14933,7 +15007,7 @@ snapshots:
shikiji: 0.9.19
source-map-js: 1.2.1
terracotta: 1.0.6([email protected])
- vite-plugin-solid: 2.10.2(@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected]))
+ vite-plugin-solid: 2.10.2(@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected]))
transitivePeerDependencies:
- '@testing-library/jest-dom'
- bufferutil
@@ -15063,13 +15137,13 @@ snapshots:
react: 18.3.1
react-dom: 18.3.1([email protected])
dependencies:
- '@storybook/csf-plugin': 8.6.0-alpha.2([email protected])
+ '@storybook/csf-plugin': 8.6.0-alpha.3([email protected])
browser-assert: 1.2.1
storybook: 8.3.3
ts-dedent: 2.2.0
- vite: 5.4.8(@types/[email protected])([email protected])
+ vite: 5.4.8(@types/[email protected])([email protected])
'@storybook/[email protected]':
dependencies:
@@ -15096,10 +15170,10 @@ snapshots:
storybook: 8.3.3
unplugin: 1.16.0
dependencies:
storybook: 8.3.3
- unplugin: 1.16.0
+ unplugin: 1.16.1
'@storybook/[email protected]':
dependencies:
@@ -15161,6 +15235,18 @@ snapshots:
'@swc/counter': 0.1.3
tslib: 2.8.0
+ optionalDependencies:
+ typescript: 5.7.2
+ zod: 3.24.1
+
+ dependencies:
+ '@t3-oss/env-core': 0.12.0([email protected])([email protected])
+ optionalDependencies:
+ typescript: 5.7.2
+ zod: 3.24.1
+
dependencies:
lodash.castarray: 4.4.0
@@ -15169,6 +15255,14 @@ snapshots:
postcss-selector-parser: 6.0.10
+ dependencies:
+ lodash.castarray: 4.4.0
+ lodash.isplainobject: 4.0.6
+ lodash.merge: 4.6.2
+ postcss-selector-parser: 6.0.10
+
'@tanstack/[email protected]': {}
@@ -15376,10 +15470,15 @@ snapshots:
'@total-typescript/[email protected]': {}
optionalDependencies:
'@types/node': 20.16.9
- zod: 3.23.8
+ zod: 3.24.1
+
+ optionalDependencies:
+ '@types/node': 22.12.0
+ zod: 3.24.1
'@tsconfig/[email protected]': {}
@@ -15389,7 +15488,7 @@ snapshots:
'@tsconfig/[email protected]': {}
dependencies:
'@turbo/workspaces': 1.13.4
chalk: 2.4.2
@@ -15399,7 +15498,7 @@ snapshots:
minimatch: 9.0.5
node-plop: 0.26.3
proxy-agent: 6.4.0
- ts-node: 10.9.2(@types/[email protected])([email protected])
+ ts-node: 10.9.2(@types/[email protected])([email protected])
update-check: 1.5.4
validate-npm-package-name: 5.0.1
transitivePeerDependencies:
@@ -15630,6 +15729,10 @@ snapshots:
dependencies:
undici-types: 6.19.8
+ '@types/[email protected]':
+ dependencies:
+ undici-types: 6.20.0
+
'@types/[email protected]': {}
'@types/[email protected]': {}
@@ -15951,7 +16054,7 @@ snapshots:
transitivePeerDependencies:
- uWebSockets.js
dependencies:
'@babel/parser': 7.25.6
acorn: 8.12.1
@@ -15962,29 +16065,29 @@ snapshots:
magicast: 0.2.11
recast: 0.23.9
tslib: 2.8.0
dependencies:
acorn: 8.12.1
acorn-loose: 8.4.0
acorn-typescript: 1.4.13([email protected])
astring: 1.9.0
magicast: 0.2.11
recast: 0.23.9
dependencies:
acorn: 8.12.1
acorn-loose: 8.4.0
acorn-typescript: 1.4.13([email protected])
astring: 1.9.0
magicast: 0.2.11
recast: 0.23.9
dependencies:
@@ -17240,7 +17343,7 @@ snapshots:
dependencies:
'@esbuild-kit/esm-loader': 2.6.5
'@hono/node-server': 1.13.1([email protected])
- '@hono/zod-validator': 0.2.2([email protected])([email protected])
+ '@hono/zod-validator': 0.2.2([email protected])([email protected])
camelcase: 7.0.1
chalk: 5.3.0
commander: 9.5.0
@@ -17254,7 +17357,7 @@ snapshots:
minimatch: 7.4.6
semver: 7.6.3
superjson: 2.2.1
- zod: 3.23.8
+ zod: 3.24.1
transitivePeerDependencies:
- supports-color
@@ -17266,9 +17369,9 @@ snapshots:
mysql2: 3.11.3
react: 18.3.1
dependencies:
- zod: 3.23.8
+ zod: 3.24.1
@@ -18280,6 +18383,14 @@ snapshots:
merge2: 1.4.1
micromatch: 4.0.8
+ dependencies:
+ '@nodelib/fs.stat': 2.0.5
+ '@nodelib/fs.walk': 1.2.8
+ glob-parent: 5.1.2
+ merge2: 1.4.1
+ micromatch: 4.0.8
+
@@ -21629,6 +21740,14 @@ snapshots:
postcss: 8.4.47
ts-node: 10.9.2(@types/[email protected])([email protected])
+ dependencies:
+ lilconfig: 3.1.2
+ yaml: 2.5.1
+ optionalDependencies:
+ postcss: 8.4.47
+ ts-node: 10.9.2(@types/[email protected])([email protected])
+
dependencies:
postcss: 8.4.47
@@ -22640,9 +22759,9 @@ snapshots:
dependencies:
internal-slot: 1.0.7
dependencies:
- '@storybook/builder-vite': 8.6.0-alpha.2([email protected])([email protected](@types/[email protected])([email protected]))
+ '@storybook/builder-vite': 8.6.0-alpha.3([email protected])([email protected](@types/[email protected])([email protected]))
transitivePeerDependencies:
- storybook
- vite
@@ -22883,10 +23002,18 @@ snapshots:
dependencies:
+ dependencies:
+
dependencies:
+ dependencies:
+
dependencies:
'@alloc/quick-lru': 5.2.0
@@ -22914,6 +23041,33 @@ snapshots:
transitivePeerDependencies:
- ts-node
+ dependencies:
+ '@alloc/quick-lru': 5.2.0
+ arg: 5.0.2
+ chokidar: 3.6.0
+ didyoumean: 1.2.2
+ dlv: 1.1.3
+ fast-glob: 3.3.2
+ glob-parent: 6.0.2
+ is-glob: 4.0.3
+ jiti: 1.21.6
+ lilconfig: 2.1.0
+ micromatch: 4.0.8
+ normalize-path: 3.0.0
+ object-hash: 3.0.0
+ picocolors: 1.1.0
+ postcss: 8.4.47
+ postcss-import: 15.1.0([email protected])
+ postcss-js: 4.0.1([email protected])
+ postcss-nested: 6.2.0([email protected])
+ postcss-selector-parser: 6.1.2
+ resolve: 1.22.8
+ sucrase: 3.35.0
+ transitivePeerDependencies:
+ - ts-node
+
@@ -23104,8 +23258,28 @@ snapshots:
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
+ dependencies:
+ '@cspotcode/source-map-support': 0.8.1
+ '@tsconfig/node10': 1.0.11
+ '@tsconfig/node12': 1.0.11
+ '@tsconfig/node14': 1.0.3
+ '@tsconfig/node16': 1.0.4
+ '@types/node': 22.12.0
+ acorn: 8.12.1
+ acorn-walk: 8.3.4
+ arg: 4.1.3
+ create-require: 1.1.1
+ diff: 4.0.2
+ make-error: 1.3.6
+ typescript: 5.7.2
+ v8-compile-cache-lib: 3.0.1
+ yn: 3.1.1
+
+
optionalDependencies:
typescript: 5.7.2
@@ -23259,6 +23433,8 @@ snapshots:
+
dependencies:
'@fastify/busboy': 2.1.1
@@ -23395,11 +23571,11 @@ snapshots:
- rollup
- webpack-sources
dependencies:
fast-glob: 3.3.2
unplugin: 1.14.1
- vite: 5.4.8(@types/[email protected])([email protected])
+ vite: 5.4.8(@types/[email protected])([email protected])
transitivePeerDependencies:
- webpack-sources
@@ -23426,6 +23602,11 @@ snapshots:
acorn: 8.14.0
webpack-virtual-modules: 0.6.2
+ dependencies:
+ acorn: 8.14.0
+ webpack-virtual-modules: 0.6.2
+
dependencies:
anymatch: 3.1.3
@@ -23610,7 +23791,7 @@ snapshots:
dependencies:
global: 4.4.0
dependencies:
'@babel/core': 7.25.2
'@babel/plugin-syntax-jsx': 7.24.7(@babel/[email protected])
@@ -23644,8 +23825,8 @@ snapshots:
unctx: 2.3.1
unenv: 1.10.0
unstorage: 1.12.0(@planetscale/[email protected])([email protected])
- vite: 5.4.8(@types/[email protected])([email protected])
- zod: 3.23.8
+ vite: 5.4.8(@types/[email protected])([email protected])
+ zod: 3.24.1
transitivePeerDependencies:
- '@azure/app-configuration'
- '@azure/cosmos'
@@ -23679,7 +23860,7 @@ snapshots:
- webpack-sources
- xml2js
dependencies:
'@babel/core': 7.25.2
'@types/babel__core': 7.20.5
@@ -23687,8 +23868,8 @@ snapshots:
merge-anything: 5.1.7
solid-js: 1.9.3
solid-refresh: 0.6.3([email protected])
- vite: 5.4.8(@types/[email protected])([email protected])
+ vite: 5.4.8(@types/[email protected])([email protected])
optionalDependencies:
'@testing-library/jest-dom': 6.5.0
transitivePeerDependencies:
@@ -23708,13 +23889,13 @@ snapshots:
- supports-color
- typescript
dependencies:
debug: 4.3.7([email protected])
globrex: 0.1.2
tsconfck: 3.1.3([email protected])
optionalDependencies:
- vite: 5.4.8(@types/[email protected])([email protected])
+ vite: 5.4.8(@types/[email protected])([email protected])
transitivePeerDependencies:
- supports-color
- typescript
@@ -23729,19 +23910,19 @@ snapshots:
fsevents: 2.3.3
terser: 5.34.0
dependencies:
esbuild: 0.21.5
postcss: 8.4.47
rollup: 4.22.5
optionalDependencies:
- '@types/node': 20.16.9
+ '@types/node': 22.12.0
fsevents: 2.3.3
terser: 5.34.0
optionalDependencies:
- vite: 5.4.8(@types/[email protected])([email protected])
+ vite: 5.4.8(@types/[email protected])([email protected])
dependencies:
@@ -23901,7 +24082,7 @@ snapshots:
dependencies:
@@ -23935,6 +24116,6 @@ snapshots:
compress-commons: 6.0.2
readable-stream: 4.5.2