Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
chore(env) - Add env check before starting app
Sara Vieira77ef3c787ba7
diff --git a/app/shared/env/env-check.js b/app/shared/env/env-check.jsnew file mode 100644index 0000000000..6d4ff966ed--- /dev/null+++ b/app/shared/env/env-check.js@@ -0,0 +1,24 @@+// @ts-check+/**+ * This file is included in `/remix.config.js` which ensures the app isn't built with invalid env vars.+ * It has to be a `.js`-file to be imported there.+ */+/* eslint-disable @typescript-eslint/no-var-requires */+const { z } = require("zod");++const envSchema = z.object({+ DATABASE_URL: z.string().url(),+ AUTH_SECRET: z.string().min(10),+});++const env = envSchema.safeParse(process.env);++if (!env.success) {+ // eslint-disable-next-line no-console+ console.error(+ "❌ Invalid environment variables:",+ JSON.stringify(env.error.format(), null, 4)+ );+ process.exit(1);+}+module.exports.env = env.data;diff --git a/package.json b/package.jsonindex 8257c6b6b7..be370051f7 100644--- a/package.json+++ b/package.json@@ -132,7 +132,8 @@"prettier": "^2.6.2","prisma": "^3.14.0","relative-deps": "^1.0.7",- "typescript": "4.6.4"+ "typescript": "4.6.4",+ "zod": "^3.17.3"},"engines": {"node": ">=14 <=16"diff --git a/remix.config.js b/remix.config.jsindex aa3040c9de..d65207f6af 100644--- a/remix.config.js+++ b/remix.config.js@@ -1,3 +1,7 @@+/* eslint-disable @typescript-eslint/no-var-requires */+// eslint-disable-next-line @typescript-eslint/no-unused-vars+const { env } = require("./app/shared/env/env-check");+/*** @type {import('@remix-run/dev').AppConfig}*/diff --git a/yarn.lock b/yarn.lockindex c61b26d9b1..28d3530356 100644--- a/yarn.lock+++ b/yarn.lock@@ -15898,6 +15898,11 @@ yocto-queue@^0.1.0:resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==+zod@^3.17.3:+ version "3.17.3"+ resolved "https://registry.yarnpkg.com/zod/-/zod-3.17.3.tgz#86abbc670ff0063a4588d85a4dcc917d6e4af2ba"+ integrity sha512-4oKP5zvG6GGbMlqBkI5FESOAweldEhSOZ6LI6cG+JzUT7ofj1ZOC0PJudpQOpT1iqOFpYYtX5Pw0+o403y4bcg==+zwitch@^1.0.0:version "1.0.5"resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-1.0.5.tgz#d11d7381ffed16b742f6af7b3f223d5cd9fe9920"