From 899d019736ccdbb163796790e46bc9feb8a3bad2 Mon Sep 17 00:00:00 2001 From: nemanjam Date: Wed, 28 Aug 2024 18:57:46 +0200 Subject: [PATCH] omit plausible url from server schema --- docs/working-notes/my-old-code/schema.ts | 10 ++++++++++ docs/working-notes/todo3.md | 1 + src/schemas/config.ts | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 docs/working-notes/my-old-code/schema.ts diff --git a/docs/working-notes/my-old-code/schema.ts b/docs/working-notes/my-old-code/schema.ts new file mode 100644 index 0000000..0dae475 --- /dev/null +++ b/docs/working-notes/my-old-code/schema.ts @@ -0,0 +1,10 @@ +.refine( + (data) => { + if (data.NODE_ENV === 'production') return Boolean(data.PLAUSIBLE_SCRIPT_URL); + return true; + }, + { + message: 'PLAUSIBLE_SCRIPT_URL is required in production', + path: ['PLAUSIBLE_SCRIPT_URL'], + } +); \ No newline at end of file diff --git a/docs/working-notes/todo3.md b/docs/working-notes/todo3.md index 7169c21..7c9a398 100644 --- a/docs/working-notes/todo3.md +++ b/docs/working-notes/todo3.md @@ -530,5 +530,6 @@ folder name for slug and index.mdx and images // plausible add zod schema that checks node_env for plausible_url instead of optional +moze samo za 1 url data-domain="nemanjamitic.com" ------------ ``` diff --git a/src/schemas/config.ts b/src/schemas/config.ts index 03afeeb..3fc7290 100644 --- a/src/schemas/config.ts +++ b/src/schemas/config.ts @@ -18,7 +18,7 @@ export const processEnvSchema = z.object({ }); export const configServerSchema = processEnvSchema - .omit({ SITE_URL: true, PREVIEW_MODE: true }) + .omit({ SITE_URL: true, PREVIEW_MODE: true, PLAUSIBLE_SCRIPT_URL: true }) .extend({ PREVIEW_MODE: z.boolean() }); // here its boolean, not 'true' | 'false' export const configClientSchema = processEnvSchema