diff --git a/.env.example b/.env.example index 6f32b5a63..fb22bbedf 100644 --- a/.env.example +++ b/.env.example @@ -7,8 +7,8 @@ NEXT_PRIVATE_GOOGLE_CLIENT_ID="" NEXT_PRIVATE_GOOGLE_CLIENT_SECRET="" # [[APP]] -NEXT_PUBLIC_SITE_URL="http://localhost:3000" -NEXT_PUBLIC_APP_URL="http://localhost:3000" +NEXT_PUBLIC_WEBAPP_URL="http://localhost:3000" +NEXT_PUBLIC_MARKETING_URL="http://localhost:3001" # [[DATABASE]] NEXT_PRIVATE_DATABASE_URL="postgres://documenso:password@127.0.0.1:54320/documenso" diff --git a/.eslintignore b/.eslintignore index f80dc7f80..b7f7e638f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,3 +5,4 @@ # Statically hosted javascript files apps/*/public/*.js apps/*/public/*.cjs +scripts/ diff --git a/apps/marketing/next.config.js b/apps/marketing/next.config.js index 2783e4063..9944b561f 100644 --- a/apps/marketing/next.config.js +++ b/apps/marketing/next.config.js @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const path = require('path'); const { withContentlayer } = require('next-contentlayer'); +const { remapVercelEnv } = require('../../scripts/remap-vercel-env.cjs'); const { parsed: env } = require('dotenv').config({ path: path.join(__dirname, '../../.env.local'), diff --git a/apps/marketing/process-env.d.ts b/apps/marketing/process-env.d.ts index ac170a616..3dfdcb30f 100644 --- a/apps/marketing/process-env.d.ts +++ b/apps/marketing/process-env.d.ts @@ -1,6 +1,7 @@ declare namespace NodeJS { export interface ProcessEnv { - NEXT_PUBLIC_SITE_URL?: string; + NEXT_PUBLIC_WEBAPP_URL?: string; + NEXT_PUBLIC_MARKETING_URL?: string; NEXT_PRIVATE_DATABASE_URL: string; diff --git a/apps/marketing/src/app/(marketing)/claimed/page.tsx b/apps/marketing/src/app/(marketing)/claimed/page.tsx index f56ae2b26..b1636e2be 100644 --- a/apps/marketing/src/app/(marketing)/claimed/page.tsx +++ b/apps/marketing/src/app/(marketing)/claimed/page.tsx @@ -161,7 +161,7 @@ export default async function ClaimedPlanPage({ searchParams = {} }: ClaimedPlan
diff --git a/apps/marketing/src/app/layout.tsx b/apps/marketing/src/app/layout.tsx index ea21ed3c3..46d9a3d32 100644 --- a/apps/marketing/src/app/layout.tsx +++ b/apps/marketing/src/app/layout.tsx @@ -21,12 +21,12 @@ export const metadata = { description: 'Join Documenso, the open signing infrastructure, and get a 10x better signing experience. Pricing starts at $30/mo. forever! Sign in now and enjoy a faster, smarter, and more beautiful document signing process. Integrates with your favorite tools, customizable, and expandable. Support our mission and become a part of our open-source community.', type: 'website', - images: [`${process.env.NEXT_PUBLIC_SITE_URL}/opengraph-image.jpg`], + images: [`${process.env.NEXT_PUBLIC_MARKETING_URL}/opengraph-image.jpg`], }, twitter: { site: '@documenso', card: 'summary_large_image', - images: [`${process.env.NEXT_PUBLIC_SITE_URL}/opengraph-image.jpg`], + images: [`${process.env.NEXT_PUBLIC_MARKETING_URL}/opengraph-image.jpg`], description: 'Join Documenso, the open signing infrastructure, and get a 10x better signing experience. Pricing starts at $30/mo. forever! Sign in now and enjoy a faster, smarter, and more beautiful document signing process. Integrates with your favorite tools, customizable, and expandable. Support our mission and become a part of our open-source community.', }, diff --git a/apps/marketing/src/pages/api/claim-plan/index.ts b/apps/marketing/src/pages/api/claim-plan/index.ts index abad354a8..3d2d8679b 100644 --- a/apps/marketing/src/pages/api/claim-plan/index.ts +++ b/apps/marketing/src/pages/api/claim-plan/index.ts @@ -43,7 +43,7 @@ export default async function handler( if (user && user.Subscription.length > 0) { return res.status(200).json({ - redirectUrl: `${process.env.NEXT_PUBLIC_APP_URL}/login`, + redirectUrl: `${process.env.NEXT_PUBLIC_WEBAPP_URL}/login`, }); } @@ -103,8 +103,8 @@ export default async function handler( mode: 'subscription', metadata, allow_promotion_codes: true, - success_url: `${process.env.NEXT_PUBLIC_SITE_URL}/claimed?sessionId={CHECKOUT_SESSION_ID}`, - cancel_url: `${process.env.NEXT_PUBLIC_SITE_URL}/pricing?email=${encodeURIComponent( + success_url: `${process.env.NEXT_PUBLIC_MARKETING_URL}/claimed?sessionId={CHECKOUT_SESSION_ID}`, + cancel_url: `${process.env.NEXT_PUBLIC_MARKETING_URL}/pricing?email=${encodeURIComponent( email, )}&name=${encodeURIComponent(name)}&planId=${planId}&cancelled=true`, }); diff --git a/apps/web/next.config.js b/apps/web/next.config.js index c3c3e1b85..d23272725 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const path = require('path'); const { version } = require('./package.json'); +const { remapVercelEnv } = require('../../scripts/remap-vercel-env.cjs'); const { parsed: env } = require('dotenv').config({ path: path.join(__dirname, '../../.env.local'), diff --git a/apps/web/process-env.d.ts b/apps/web/process-env.d.ts index 1cb0018ac..4149423dd 100644 --- a/apps/web/process-env.d.ts +++ b/apps/web/process-env.d.ts @@ -1,6 +1,7 @@ declare namespace NodeJS { export interface ProcessEnv { - NEXT_PUBLIC_SITE_URL?: string; + NEXT_PUBLIC_WEBAPP_URL?: string; + NEXT_PUBLIC_MARKETING_URL?: string; NEXT_PRIVATE_DATABASE_URL: string; diff --git a/apps/web/src/app/(dashboard)/settings/billing/page.tsx b/apps/web/src/app/(dashboard)/settings/billing/page.tsx index 555c645ce..bd2659e62 100644 --- a/apps/web/src/app/(dashboard)/settings/billing/page.tsx +++ b/apps/web/src/app/(dashboard)/settings/billing/page.tsx @@ -35,7 +35,7 @@ export default async function BillingSettingsPage() { if (subscription.customerId) { billingPortalUrl = await getPortalSession({ customerId: subscription.customerId, - returnUrl: `${process.env.NEXT_PUBLIC_SITE_URL}/settings/billing`, + returnUrl: `${process.env.NEXT_PUBLIC_WEBAPP_URL}/settings/billing`, }); } diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx index 2ce8744d4..2a1d082f9 100644 --- a/apps/web/src/app/layout.tsx +++ b/apps/web/src/app/layout.tsx @@ -33,12 +33,12 @@ export const metadata = { description: 'Join Documenso, the open signing infrastructure, and get a 10x better signing experience. Pricing starts at $30/mo. forever! Sign in now and enjoy a faster, smarter, and more beautiful document signing process. Integrates with your favorite tools, customizable, and expandable. Support our mission and become a part of our open-source community.', type: 'website', - images: [`${process.env.NEXT_PUBLIC_SITE_URL}/opengraph-image.jpg`], + images: [`${process.env.NEXT_PUBLIC_WEBAPP_URL}/opengraph-image.jpg`], }, twitter: { site: '@documenso', card: 'summary_large_image', - images: [`${process.env.NEXT_PUBLIC_SITE_URL}/opengraph-image.jpg`], + images: [`${process.env.NEXT_PUBLIC_WEBAPP_URL}/opengraph-image.jpg`], description: 'Join Documenso, the open signing infrastructure, and get a 10x better signing experience. Pricing starts at $30/mo. forever! Sign in now and enjoy a faster, smarter, and more beautiful document signing process. Integrates with your favorite tools, customizable, and expandable. Support our mission and become a part of our open-source community.', }, diff --git a/apps/web/src/helpers/get-feature-flag.ts b/apps/web/src/helpers/get-feature-flag.ts index 3b6c66528..d5cd26c33 100644 --- a/apps/web/src/helpers/get-feature-flag.ts +++ b/apps/web/src/helpers/get-feature-flag.ts @@ -21,7 +21,7 @@ export const getFlag = async ( return LOCAL_FEATURE_FLAGS[flag] ?? true; } - const url = new URL(`${process.env.NEXT_PUBLIC_SITE_URL}/api/feature-flag/get`); + const url = new URL(`${process.env.NEXT_PUBLIC_WEBAPP_URL}/api/feature-flag/get`); url.searchParams.set('flag', flag); const response = await fetch(url, { @@ -54,7 +54,7 @@ export const getAllFlags = async ( return LOCAL_FEATURE_FLAGS; } - const url = new URL(`${process.env.NEXT_PUBLIC_SITE_URL}/api/feature-flag/all`); + const url = new URL(`${process.env.NEXT_PUBLIC_WEBAPP_URL}/api/feature-flag/all`); return fetch(url, { headers: { diff --git a/apps/web/src/pages/api/claim-plan/index.ts b/apps/web/src/pages/api/claim-plan/index.ts index abad354a8..3d2d8679b 100644 --- a/apps/web/src/pages/api/claim-plan/index.ts +++ b/apps/web/src/pages/api/claim-plan/index.ts @@ -43,7 +43,7 @@ export default async function handler( if (user && user.Subscription.length > 0) { return res.status(200).json({ - redirectUrl: `${process.env.NEXT_PUBLIC_APP_URL}/login`, + redirectUrl: `${process.env.NEXT_PUBLIC_WEBAPP_URL}/login`, }); } @@ -103,8 +103,8 @@ export default async function handler( mode: 'subscription', metadata, allow_promotion_codes: true, - success_url: `${process.env.NEXT_PUBLIC_SITE_URL}/claimed?sessionId={CHECKOUT_SESSION_ID}`, - cancel_url: `${process.env.NEXT_PUBLIC_SITE_URL}/pricing?email=${encodeURIComponent( + success_url: `${process.env.NEXT_PUBLIC_MARKETING_URL}/claimed?sessionId={CHECKOUT_SESSION_ID}`, + cancel_url: `${process.env.NEXT_PUBLIC_MARKETING_URL}/pricing?email=${encodeURIComponent( email, )}&name=${encodeURIComponent(name)}&planId=${planId}&cancelled=true`, }); diff --git a/assets/example.pdf b/assets/example.pdf new file mode 100644 index 000000000..f908d84e1 Binary files /dev/null and b/assets/example.pdf differ diff --git a/package-lock.json b/package-lock.json index f4cf47807..39b1a1841 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3489,12 +3489,12 @@ } }, "node_modules/@prisma/client": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.0.0.tgz", - "integrity": "sha512-XlO5ELNAQ7rV4cXIDJUNBEgdLwX3pjtt9Q/RHqDpGf43szpNJx2hJnggfFs7TKNx0cOFsl6KJCSfqr5duEU/bQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.3.1.tgz", + "integrity": "sha512-ArOKjHwdFZIe1cGU56oIfy7wRuTn0FfZjGuU/AjgEBOQh+4rDkB6nF+AGHP8KaVpkBIiHGPQh3IpwQ3xDMdO0Q==", "hasInstallScript": true, "dependencies": { - "@prisma/engines-version": "4.17.0-26.6b0aef69b7cdfc787f822ecd7cdc76d5f1991584" + "@prisma/engines-version": "5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59" }, "engines": { "node": ">=16.13" @@ -3509,15 +3509,15 @@ } }, "node_modules/@prisma/engines": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.0.0.tgz", - "integrity": "sha512-kyT/8fd0OpWmhAU5YnY7eP31brW1q1YrTGoblWrhQJDiN/1K+Z8S1kylcmtjqx5wsUGcP1HBWutayA/jtyt+sg==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.3.1.tgz", + "integrity": "sha512-6QkILNyfeeN67BNEPEtkgh3Xo2tm6D7V+UhrkBbRHqKw9CTaz/vvTP/ROwYSP/3JT2MtIutZm/EnhxUiuOPVDA==", "hasInstallScript": true }, "node_modules/@prisma/engines-version": { - "version": "4.17.0-26.6b0aef69b7cdfc787f822ecd7cdc76d5f1991584", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-4.17.0-26.6b0aef69b7cdfc787f822ecd7cdc76d5f1991584.tgz", - "integrity": "sha512-HHiUF6NixsldsP3JROq07TYBLEjXFKr6PdH8H4gK/XAoTmIplOJBCgrIUMrsRAnEuGyRoRLXKXWUb943+PFoKQ==" + "version": "5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59.tgz", + "integrity": "sha512-y5qbUi3ql2Xg7XraqcXEdMHh0MocBfnBzDn5GbV1xk23S3Mq8MGs+VjacTNiBh3dtEdUERCrUUG7Z3QaJ+h79w==" }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", @@ -14820,12 +14820,12 @@ "integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew==" }, "node_modules/prisma": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.0.0.tgz", - "integrity": "sha512-KYWk83Fhi1FH59jSpavAYTt2eoMVW9YKgu8ci0kuUnt6Dup5Qy47pcB4/TLmiPAbhGrxxSz7gsSnJcCmkyPANA==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.3.1.tgz", + "integrity": "sha512-Wp2msQIlMPHe+5k5Od6xnsI/WNG7UJGgFUJgqv/ygc7kOECZapcSz/iU4NIEzISs3H1W9sFLjAPbg/gOqqtB7A==", "hasInstallScript": true, "dependencies": { - "@prisma/engines": "5.0.0" + "@prisma/engines": "5.3.1" }, "bin": { "prisma": "build/index.js" @@ -18417,8 +18417,12 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@prisma/client": "5.0.0", - "prisma": "5.0.0" + "@prisma/client": "5.3.1", + "prisma": "5.3.1" + }, + "devDependencies": { + "ts-node": "^10.9.1", + "typescript": "^5.1.6" } }, "packages/tailwind-config": { diff --git a/packages/lib/server-only/document/send-document.tsx b/packages/lib/server-only/document/send-document.tsx index 37ecc66b7..83a88f24a 100644 --- a/packages/lib/server-only/document/send-document.tsx +++ b/packages/lib/server-only/document/send-document.tsx @@ -48,8 +48,8 @@ export const sendDocument = async ({ documentId, userId }: SendDocumentOptions) return; } - const assetBaseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000'; - const signDocumentLink = `${process.env.NEXT_PUBLIC_SITE_URL}/sign/${recipient.token}`; + const assetBaseUrl = process.env.NEXT_PUBLIC_WEBAPP_URL || 'http://localhost:3000'; + const signDocumentLink = `${process.env.NEXT_PUBLIC_WEBAPP_URL}/sign/${recipient.token}`; const template = createElement(DocumentInviteEmailTemplate, { documentName: document.title, diff --git a/packages/lib/universal/get-base-url.ts b/packages/lib/universal/get-base-url.ts index aa8884088..2120c9f54 100644 --- a/packages/lib/universal/get-base-url.ts +++ b/packages/lib/universal/get-base-url.ts @@ -8,8 +8,8 @@ export const getBaseUrl = () => { return `https://${process.env.VERCEL_URL}`; } - if (process.env.NEXT_PUBLIC_SITE_URL) { - return `https://${process.env.NEXT_PUBLIC_SITE_URL}`; + if (process.env.NEXT_PUBLIC_WEBAPP_URL) { + return process.env.NEXT_PUBLIC_WEBAPP_URL; } return `http://localhost:${process.env.PORT ?? 3000}`; diff --git a/packages/prisma/helper.ts b/packages/prisma/helper.ts new file mode 100644 index 000000000..d436771d1 --- /dev/null +++ b/packages/prisma/helper.ts @@ -0,0 +1,52 @@ +///