Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

prepare docker image for proper release (#608)

Brendan Allan15742f156884
diff --git a/.github/workflows/docker-build-web.yml b/.github/workflows/docker-build-web.yml
index 5161e6ead..d2814da12 100644
--- a/.github/workflows/docker-build-web.yml
+++ b/.github/workflows/docker-build-web.yml
@@ -4,9 +4,9 @@ on:
workflow_dispatch:
inputs:
tag:
- description: 'Tag for the Docker image'
+ description: "Tag for the Docker image"
required: false
- default: 'latest'
+ default: "latest"
type: string
jobs:
@@ -23,10 +23,11 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
+
- name: Create .env file
run: |
echo "WEB_URL=http://localhost:3000" > .env
+ echo "DOCKER_BUILD=true" >> .env
echo "NEXT_PUBLIC_CAP_AWS_BUCKET=capso" >> .env
echo "NEXT_PUBLIC_CAP_AWS_REGION=us-east-1" >> .env
cat .env
@@ -59,4 +60,4 @@ jobs:
cache-to: type=gha,mode=max
- name: Show Docker Images
- run: docker images
\ No newline at end of file
+ run: docker images
diff --git a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx
index 8c609ae36..9fdba6534 100644
--- a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx
@@ -259,16 +259,19 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
<ServerURLSetting
value={settings.serverUrl ?? "https://cap.so"}
onChange={async (v) => {
+ const url = new URL(v);
+ const origin = url.origin;
+
if (
!(await confirm(
- `Are you sure you want to change the server URL to '${v}'? You will need to sign in again.`
+ `Are you sure you want to change the server URL to '${origin}'? You will need to sign in again.`
))
)
return;
await authStore.set(undefined);
- await commands.setServerUrl(v);
- handleChange("serverUrl", v);
+ await commands.setServerUrl(origin);
+ handleChange("serverUrl", origin);
}}
/>
</div>
diff --git a/apps/desktop/src/utils/auth.ts b/apps/desktop/src/utils/auth.ts
index 71f9d283a..09ad0eadc 100644
--- a/apps/desktop/src/utils/auth.ts
+++ b/apps/desktop/src/utils/auth.ts
@@ -95,20 +95,28 @@ async function createLocalServerSession(signal: AbortSignal) {
if (signal.aborted) throw new Error("Sign in aborted");
- return paramsValidator.parse({
- type: url.searchParams.get("type"),
- api_key: url.searchParams.get("api_key"),
- user_id: url.searchParams.get("user_id"),
- });
+ const a = [...url.searchParams].reduce((acc, [k, v]) => {
+ acc[k] = v;
+ return acc;
+ }, {} as any);
+
+ return paramsValidator.parse(a);
},
};
}
-const paramsValidator = z.object({
- type: z.literal("api_key"),
- api_key: z.string(),
- user_id: z.string(),
-});
+const paramsValidator = z.union([
+ z.object({
+ type: z.literal("api_key"),
+ api_key: z.string(),
+ user_id: z.string(),
+ }),
+ z.object({
+ token: z.string(),
+ user_id: z.string(),
+ expires: z.coerce.number(),
+ }),
+]);
async function createDeepLinkSession(signal: AbortSignal) {
let res: (data: z.infer<typeof paramsValidator>) => void;
@@ -122,11 +130,12 @@ async function createDeepLinkSession(signal: AbortSignal) {
const url = new URL(urlString);
res(
- paramsValidator.parse({
- type: url.searchParams.get("type"),
- api_key: url.searchParams.get("api_key"),
- user_id: url.searchParams.get("user_id"),
- })
+ paramsValidator.parse(
+ [...url.searchParams].reduce((acc, [k, v]) => {
+ acc[k] = v;
+ return acc;
+ }, {} as any)
+ )
);
}
});
@@ -147,7 +156,10 @@ async function processAuthData(data: z.infer<typeof paramsValidator>) {
const existingAuth = await authStore.get();
await authStore.set({
- secret: { api_key: data.api_key },
+ secret:
+ "api_key" in data
+ ? { api_key: data.api_key }
+ : { token: data.token, expires: data.expires },
user_id: data.user_id,
intercom_hash: existingAuth?.intercom_hash ?? "",
plan: null,
diff --git a/apps/web/app/api/selfhosted/migrations/route.ts b/apps/web/app/api/selfhosted/migrations/route.ts
index db28d63f0..b18b35bdc 100644
--- a/apps/web/app/api/selfhosted/migrations/route.ts
+++ b/apps/web/app/api/selfhosted/migrations/route.ts
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
import { db } from "@cap/database";
import { migrate } from "drizzle-orm/mysql2/migrator";
import path from "path";
-import { serverEnv } from "@cap/env";
+import { buildEnv } from "@cap/env";
const migrations = {
run: false,
@@ -16,7 +16,7 @@ export async function POST() {
});
}
- const isDockerBuild = serverEnv().DOCKER_BUILD === "true";
+ const isDockerBuild = buildEnv.NEXT_PUBLIC_DOCKER_BUILD === "true";
if (isDockerBuild) {
try {
console.log("🔍 DB migrations triggered");
diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
index 97f7d8eeb..8fb414f3f 100644
--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
@@ -14,7 +14,7 @@ import {
DialogTrigger,
Popover,
PopoverContent,
- PopoverTrigger
+ PopoverTrigger,
} from "@cap/ui";
import { classNames } from "@cap/utils";
import { Check, ChevronDown, Plus } from "lucide-react";
@@ -38,7 +38,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import clsx from "clsx";
import { motion } from "framer-motion";
import Image from "next/image";
-
+
import { useRef, useState } from "react";
import { updateActiveOrganization } from "./server";
@@ -50,8 +50,7 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
const pathname = usePathname();
const [open, setOpen] = useState(false);
const [hoveredItem, setHoveredItem] = useState<string | null>(null);
- const { user, sidebarCollapsed } =
- useSharedContext();
+ const { user, sidebarCollapsed } = useSharedContext();
const manageNavigation = [
{
@@ -94,8 +93,11 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
"flex items-center justify-start px-3 rounded-xl outline-none tracking-tight overflow-hidden";
const [dialogOpen, setDialogOpen] = useState(false);
- const { organizationData: orgData, activeOrganization: activeOrg, isSubscribed: userIsSubscribed } =
- useSharedContext();
+ const {
+ organizationData: orgData,
+ activeOrganization: activeOrg,
+ isSubscribed: userIsSubscribed,
+ } = useSharedContext();
const formRef = useRef<HTMLFormElement | null>(null);
const [createLoading, setCreateLoading] = useState(false);
const [organizationName, setOrganizationName] = useState("");
@@ -106,9 +108,7 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
<Tooltip
disable={open || sidebarCollapsed === false}
position="right"
- content={
- activeOrg?.organization.name ?? "No organization found"
- }
+ content={activeOrg?.organization.name ?? "No organization found"}
>
<PopoverTrigger asChild>
<motion.div
@@ -123,11 +123,9 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
bounce: 0.2,
width: { type: "tween", duration: 0.2 },
}}
- className={
- clsx(
- "p-2.5 mt-2.5 rounded-xl border cursor-pointer bg-gradient-to-t from-gray-4 to-gray-2 border-gray-4",
- )
- }
+ className={clsx(
+ "p-2.5 mt-2.5 rounded-xl border cursor-pointer bg-gradient-to-t from-gray-4 to-gray-2 border-gray-4"
+ )}
>
<div
className="flex justify-between items-center cursor-pointer"
@@ -140,7 +138,9 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
<div className="overflow-hidden relative flex-shrink-0 rounded-full size-[18px]">
<Image
src={activeOrg.organization.iconUrl}
- alt={activeOrg.organization.name || "Organization icon"}
+ alt={
+ activeOrg.organization.name || "Organization icon"
+ }
fill
className="object-cover"
/>
@@ -156,12 +156,14 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
/>
)}
<p className="ml-2.5 text-sm text-gray-12 truncate">
- {activeOrg?.organization.name ??
- "No organization found"}
+ {activeOrg?.organization.name ?? "No organization found"}
</p>
</div>
{!sidebarCollapsed && (
- <ChevronDown data-state={open ? "open" : "closed"} className="w-5 h-auto transition-transform duration-200 text-gray-8 data-[state=open]:rotate-180" />
+ <ChevronDown
+ data-state={open ? "open" : "closed"}
+ className="w-5 h-auto transition-transform duration-200 text-gray-8 data-[state=open]:rotate-180"
+ />
)}
</div>
</div>
@@ -183,7 +185,9 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
<CommandItem
className={clsx(
"rounded-lg transition-colors duration-300 group",
- isSelected ? "pointer-events-none":"text-gray-10 hover:text-gray-12 hover:bg-gray-6"
+ isSelected
+ ? "pointer-events-none"
+ : "text-gray-10 hover:text-gray-12 hover:bg-gray-6"
)}
key={organization.organization.name + "-organization"}
onSelect={async () => {
@@ -198,7 +202,10 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
<div className="overflow-hidden relative flex-shrink-0 rounded-full size-5">
<Image
src={organization.organization.iconUrl}
- alt={organization.organization.name || "Organization icon"}
+ alt={
+ organization.organization.name ||
+ "Organization icon"
+ }
fill
className="object-cover"
/>
@@ -210,7 +217,14 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
name={organization.organization.name}
/>
)}
- <p className={clsx("flex-1 text-sm transition-colors duration-200 group-hover:text-gray-12", isSelected ? "text-gray-12":"text-gray-10")}>{organization.organization.name}</p>
+ <p
+ className={clsx(
+ "flex-1 text-sm transition-colors duration-200 group-hover:text-gray-12",
+ isSelected ? "text-gray-12" : "text-gray-10"
+ )}
+ >
+ {organization.organization.name}
+ </p>
</div>
{isSelected && (
<Check
@@ -243,10 +257,16 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
aria-label="Sidebar"
>
<div
- className={clsx("mt-8", sidebarCollapsed ? "flex flex-col justify-center items-center" : "")}
+ className={clsx(
+ "mt-8",
+ sidebarCollapsed ? "flex flex-col justify-center items-center" : ""
+ )}
>
{manageNavigation.map((item) => (
- <div key={item.name} className="flex relative justify-center items-center w-full mb-2.5">
+ <div
+ key={item.name}
+ className="flex relative justify-center items-center w-full mb-2.5"
+ >
{/* Active indicator - always visible for active items */}
{pathname.includes(item.href) && (
<motion.div
@@ -268,18 +288,22 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
id="underline"
className={clsx(
"absolute rounded-xl border bg-gray-3 border-gray-4",
- sidebarCollapsed ? "inset-0 right-0 left-0 mx-auto w-9 h-9" : "inset-0 ml-[2px]"
+ sidebarCollapsed
+ ? "inset-0 right-0 left-0 mx-auto w-9 h-9"
+ : "inset-0 ml-[2px]"
)}
/>
)}
-
+
{/* Hover indicator - only visible when hovering non-active items */}
{hoveredItem === item.name && !pathname.includes(item.href) && (
<motion.div
layoutId="hoverIndicator"
className={clsx(
"absolute bg-transparent rounded-xl border-gray-4 border-[1px]",
- sidebarCollapsed ? "inset-0 right-0 left-0 mx-auto w-9 h-9" : "inset-0 ml-[2px]"
+ sidebarCollapsed
+ ? "inset-0 right-0 left-0 mx-auto w-9 h-9"
+ : "inset-0 ml-[2px]"
)}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
@@ -305,7 +329,9 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
href={item.href}
className={classNames(
"relative border border-transparent transition-opacity duration-200 z-3",
- sidebarCollapsed ? "flex justify-center items-center w-full h-9" : "py-2 w-full",
+ sidebarCollapsed
+ ? "flex justify-center items-center w-full h-9"
+ : "py-2 w-full",
navItemClass
)}
>
@@ -317,7 +343,12 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
)}
aria-hidden="true"
/>
- <p className={clsx("text-sm text-gray-12 truncate", sidebarCollapsed ? "hidden" : "ml-2.5")}>
+ <p
+ className={clsx(
+ "text-sm text-gray-12 truncate",
+ sidebarCollapsed ? "hidden" : "ml-2.5"
+ )}
+ >
{item.name}
</p>
</Link>
@@ -326,23 +357,28 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
))}
</div>
<div className="pb-0 w-full lg:pb-5">
- <UsageButton
- toggleMobileNav={() =>
- toggleMobileNav?.()
- }
- subscribed={userIsSubscribed}
- />
+ {buildEnv.NEXT_PUBLIC_IS_CAP && (
+ <UsageButton
+ toggleMobileNav={() => toggleMobileNav?.()}
+ subscribed={userIsSubscribed}
+ />
+ )}
<p className="mt-4 text-xs text-center truncate text-gray-10">
Cap Software, Inc. {new Date().getFullYear()}.
</p>
</div>
</nav>
<DialogContent className="p-0 w-full max-w-md rounded-xl border bg-gray-2 border-gray-4">
- <DialogHeader icon={<FontAwesomeIcon icon={faBuilding} />} description="A new organization to share caps with your team">
- <DialogTitle className="text-lg text-gray-12">Create New Organization</DialogTitle>
+ <DialogHeader
+ icon={<FontAwesomeIcon icon={faBuilding} />}
+ description="A new organization to share caps with your team"
+ >
+ <DialogTitle className="text-lg text-gray-12">
+ Create New Organization
+ </DialogTitle>
</DialogHeader>
<div className="p-5">
- <NewOrganization
+ <NewOrganization
setCreateLoading={setCreateLoading}
onOrganizationCreated={() => setDialogOpen(false)}
formRef={formRef}
@@ -350,16 +386,12 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
/>
</div>
<DialogFooter>
- <Button
- variant="gray"
- size="sm"
- onClick={() => setDialogOpen(false)}
- >
+ <Button variant="gray" size="sm" onClick={() => setDialogOpen(false)}>
Cancel
</Button>
- <Button
- variant="dark"
- size="sm"
+ <Button
+ variant="dark"
+ size="sm"
disabled={createLoading || !organizationName.trim().length}
spinner={createLoading}
onClick={() => formRef.current?.requestSubmit()}
diff --git a/apps/web/app/dashboard/_components/DashboardInner.tsx b/apps/web/app/dashboard/_components/DashboardInner.tsx
index 7aabe6044..e8972e000 100644
--- a/apps/web/app/dashboard/_components/DashboardInner.tsx
+++ b/apps/web/app/dashboard/_components/DashboardInner.tsx
@@ -6,6 +6,7 @@ import {
} from "@/app/dashboard/_components/DynamicSharedLayout";
import { Avatar } from "@/app/s/[videoId]/_components/tabs/Activity";
import { UpgradeModal } from "@/components/UpgradeModal";
+import { buildEnv } from "@cap/env";
import {
Command,
CommandGroup,
@@ -95,8 +96,10 @@ const User = () => {
/>
<Popover open={menuOpen} onOpenChange={setMenuOpen}>
<PopoverTrigger asChild>
- <div data-state={menuOpen ? "open" : "closed"}
- className="flex gap-2 justify-between items-center p-2 rounded-xl border data-[state=open]:border-gray-5 data-[state=open]:bg-gray-3 border-transparent transition-colors cursor-pointer group lg:gap-6 hover:border-gray-4">
+ <div
+ data-state={menuOpen ? "open" : "closed"}
+ className="flex gap-2 justify-between items-center p-2 rounded-xl border data-[state=open]:border-gray-5 data-[state=open]:bg-gray-3 border-transparent transition-colors cursor-pointer group lg:gap-6 hover:border-gray-4"
+ >
<div className="flex items-center">
<Avatar
letterClass="text-xs lg:text-md"
@@ -107,7 +110,10 @@ const User = () => {
{user.name ?? "User"}
</span>
</div>
- <MoreVertical data-state={menuOpen ? "open" : "closed"} className="w-5 h-5 data-[state=open]:text-gray-12 transition-colors text-gray-10 group-hover:text-gray-12" />
+ <MoreVertical
+ data-state={menuOpen ? "open" : "closed"}
+ className="w-5 h-5 data-[state=open]:text-gray-12 transition-colors text-gray-10 group-hover:text-gray-12"
+ />
</div>
</PopoverTrigger>
<PopoverContent className="p-1 w-48">
@@ -129,7 +135,7 @@ const User = () => {
</span>
</CommandItem>
</Link>
- {!isSubscribed && (
+ {!isSubscribed && buildEnv.NEXT_PUBLIC_IS_CAP && (
<CommandItem
className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
onSelect={() => {
diff --git a/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx b/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx
index 3292db347..a5710af79 100644
--- a/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx
+++ b/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx
@@ -6,6 +6,7 @@ import { users } from "@cap/database/schema";
import Cookies from "js-cookie";
import { createContext, useContext, useEffect, useState } from "react";
import AdminDesktopNav from "./AdminNavbar/AdminDesktopNav";
+import { buildEnv } from "@cap/env";
type SharedContext = {
organizationData: Organization[] | null;
@@ -107,10 +108,12 @@ export default function DynamicSharedLayout({
</div>
{/* Global upgrade modal that persists regardless of navigation state */}
- <UpgradeModal
- open={upgradeModalOpen}
- onOpenChange={setUpgradeModalOpen}
- />
+ {buildEnv.NEXT_PUBLIC_IS_CAP && (
+ <UpgradeModal
+ open={upgradeModalOpen}
+ onOpenChange={setUpgradeModalOpen}
+ />
+ )}
</div>
</Context.Provider>
</ThemeContext.Provider>
diff --git a/apps/web/components/UpgradeModal.tsx b/apps/web/components/UpgradeModal.tsx
index 0a0228971..4bbafdd68 100644
--- a/apps/web/components/UpgradeModal.tsx
+++ b/apps/web/components/UpgradeModal.tsx
@@ -1,5 +1,6 @@
"use client";
+import { buildEnv } from "@cap/env";
import { Button, Dialog, DialogContent, DialogTitle, Switch } from "@cap/ui";
import { getProPlanId } from "@cap/utils";
import NumberFlow from "@number-flow/react";
@@ -57,6 +58,8 @@ const modalVariants = {
};
export const UpgradeModal = ({ open, onOpenChange }: UpgradeModalProps) => {
+ if (buildEnv.NEXT_PUBLIC_IS_CAP !== "true") return;
+
const [proLoading, setProLoading] = useState(false);
const [isAnnual, setIsAnnual] = useState(true);
const [proQuantity, setProQuantity] = useState(1);
@@ -166,7 +169,7 @@ export const UpgradeModal = ({ open, onOpenChange }: UpgradeModalProps) => {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent
- className="sm:max-w-[1100px] w-[calc(100%-20px)] custom-scroll bg-gray-2 border
+ className="sm:max-w-[1100px] w-[calc(100%-20px)] custom-scroll bg-gray-2 border
border-gray-4 overflow-y-auto md:overflow-hidden max-h-[90vh] p-0"
>
<DialogTitle className="sr-only">Upgrade to Cap Pro</DialogTitle>
diff --git a/apps/web/components/pages/DocsPage.tsx b/apps/web/components/pages/DocsPage.tsx
index d8feb5b74..e36bcefcc 100644
--- a/apps/web/components/pages/DocsPage.tsx
+++ b/apps/web/components/pages/DocsPage.tsx
@@ -30,7 +30,7 @@ export const DocsPage = () => {
</div>
)}
<div className="p-10 space-y-4">
- <h2 className="text-xl text-gray-1 md:text-4xl">
+ <h2 className="text-xl text-gray-12 md:text-4xl">
{doc.metadata.title}
</h2>
<p className="text-gray-600">{doc.metadata.summary}</p>
@@ -39,7 +39,7 @@ export const DocsPage = () => {
doc.metadata.tags.split(", ").map((tag) => (
<p
key={tag}
- className="rounded-md bg-gray-200 font-medium px-2 py-0.5 text-sm text-gray-1"
+ className="rounded-md bg-gray-4 font-medium px-2 py-0.5 text-sm text-gray-11"
>
{tag}
</p>
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index f25fd944e..002113c07 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -36,7 +36,8 @@ export async function middleware(request: NextRequest) {
path.startsWith("/invite") ||
path.startsWith("/self-hosting") ||
path.startsWith("/terms")
- )
+ ) &&
+ process.env.NODE_ENV !== "development"
)
return NextResponse.redirect(new URL("/login", url.origin));
else return NextResponse.next();
diff --git a/docker-compose.template.yml b/docker-compose.template.yml
index 1f057badc..fbac33b4b 100644
--- a/docker-compose.template.yml
+++ b/docker-compose.template.yml
@@ -7,14 +7,12 @@ name: cap-so-docker-template
services:
cap-web:
container_name: cap-web
- image: cap-web-docker:latest
+ image: ghcr.io/capsoftware/cap-web:latest
restart: unless-stopped
environment:
DATABASE_URL: 'mysql://root:@ps-mysql:3306/planetscale?ssl={"rejectUnauthorized":false}'
- DATABASE_MIGRATION_URL: 'mysql://root:@ps-mysql:3306/planetscale?ssl={"rejectUnauthorized":false}'
WEB_URL: http://localhost:3000
NEXTAUTH_URL: http://localhost:3000
- DOCKER_BUILD: true
# CHANGE THESE TO YOUR OWN VALUES
DATABASE_ENCRYPTION_KEY: c7a1e98e1e5e4cec5a3fbf5eaf502d262fb99807ae2be8ee70537409e29cb6f9
NEXTAUTH_SECRET: c7a1e98e1e5e4cec5a3fbf5eaf502d262fb99807ae2be8ee70537409e29cb6f9
diff --git a/packages/database/drizzle.config.ts b/packages/database/drizzle.config.ts
index 9fe06262a..788afd72f 100644
--- a/packages/database/drizzle.config.ts
+++ b/packages/database/drizzle.config.ts
@@ -2,21 +2,12 @@ import type { Config } from "drizzle-kit";
const URL = process.env.DATABASE_MIGRATION_URL ?? process.env.DATABASE_URL;
-// if (!URL)
-// throw new Error("DATABASE_URL or DATABASE_MIGRATION_URL must be set!");
-// if (!URL?.startsWith("mysql://"))
-// throw new Error(
-// "DATABASE_URL must be a 'mysql://' URI. Drizzle Kit doesn't support the fetch adapter!"
-// );
-
-// export default {
-// schema: "./schema.ts",
-// dbCredentials: {
-// uri: URL,
-// },
-// out: "./migrations",
-// driver: "mysql2",
-// } satisfies Config;
+if (!URL)
+ throw new Error("DATABASE_URL or DATABASE_MIGRATION_URL must be set!");
+if (!URL?.startsWith("mysql://"))
+ throw new Error(
+ "DATABASE_URL must be a 'mysql://' URI. Drizzle Kit doesn't support the fetch adapter!"
+ );
export default {
schema: "./schema.ts",
@@ -24,4 +15,4 @@ export default {
dialect: "mysql",
dbCredentials: { url: URL },
casing: "snake_case",
-} satisfies Config;
\ No newline at end of file
+} satisfies Config;
diff --git a/packages/database/emails/config.ts b/packages/database/emails/config.ts
index eacdea0b9..d2b001859 100644
--- a/packages/database/emails/config.ts
+++ b/packages/database/emails/config.ts
@@ -34,14 +34,16 @@ export const sendEmail = async ({
return Promise.resolve();
}
+ if (marketing && !buildEnv.NEXT_PUBLIC_IS_CAP) return;
+ let from;
+
+ if (marketing) from = "Richie from Cap <[email protected]>";
+ else if (buildEnv.NEXT_PUBLIC_IS_CAP)
+ from = "Cap Auth <[email protected]>";
+ else from = `auth@${serverEnv().RESEND_FROM_DOMAIN}`;
+
return r.emails.send({
- from: marketing
- ? "Richie from Cap <[email protected]>"
- : buildEnv.NEXT_PUBLIC_IS_CAP
- ? "Cap Auth <[email protected]>"
- : `auth@${
- serverEnv().RESEND_FROM_DOMAIN ?? buildEnv.NEXT_PUBLIC_WEB_URL
- }`,
+ from,
to: test ? "[email protected]" : email,
subject,
react,
diff --git a/packages/env/build.ts b/packages/env/build.ts
index 200c8cfef..ad2566fc1 100644
--- a/packages/env/build.ts
+++ b/packages/env/build.ts
@@ -15,6 +15,7 @@ export const buildEnv = createEnv({
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_DOCKER_BUILD: z.string().optional(),
},
runtimeEnv: {
NEXT_PUBLIC_IS_CAP: process.env.NEXT_PUBLIC_IS_CAP,
@@ -29,5 +30,6 @@ export const buildEnv = createEnv({
process.env.CAP_AWS_ENDPOINT ?? process.env.NEXT_PUBLIC_CAP_AWS_ENDPOINT,
NEXT_PUBLIC_CAP_AWS_BUCKET_URL:
process.env.CAP_AWS_URL ?? process.env.NEXT_PUBLIC_CAP_AWS_BUCKET_URL,
+ NEXT_PUBLIC_DOCKER_BUILD: process.env.NEXT_PUBLIC_DOCKER_BUILD,
},
});