apps/web: add zod env validation
This commit is contained in:
parent
7b42fd4548
commit
13b22aa55a
3
apps/web/config/env.ts
Normal file
3
apps/web/config/env.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import envSchema from './schema/env';
|
||||
|
||||
export const env = envSchema.parse(process.env);
|
||||
7
apps/web/config/schema/env.ts
Normal file
7
apps/web/config/schema/env.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const envSchema = z.object({
|
||||
USE_DEV_COLORS: z.string(),
|
||||
});
|
||||
|
||||
export default envSchema;
|
||||
@ -1,3 +1,5 @@
|
||||
import { env } from '../config/env';
|
||||
|
||||
export const COLORS_PROD = {
|
||||
COLOR_DANGER: '#D10000',
|
||||
COLOR_PRIMARY: '#1C01A9',
|
||||
@ -5,7 +7,10 @@ export const COLORS_PROD = {
|
||||
COLOR_TERTIARTY: '#580161',
|
||||
};
|
||||
export const COLORS_DEV = {
|
||||
COLOR_DANGER: '#D10000',
|
||||
COLOR_PRIMARY: '#BF3676',
|
||||
COLOR_SECONDARY: '#FD4047',
|
||||
COLOR_TERTIARTY: '#FF9112',
|
||||
};
|
||||
|
||||
export const COLORS = env.USE_DEV_COLORS ? COLORS_DEV : COLORS_PROD;
|
||||
|
||||
@ -14,7 +14,8 @@
|
||||
"react-dom": "^18",
|
||||
"tailwind-tints": "^1.1.0",
|
||||
"tsconfig": "*",
|
||||
"ui": "*"
|
||||
"ui": "*",
|
||||
"zod": "^3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { COLORS_PROD } from './constants/colors';
|
||||
import { COLORS } from './constants/colors';
|
||||
import tailwindTints from 'tailwind-tints';
|
||||
import type { Config } from 'tailwindcss';
|
||||
|
||||
const tints = tailwindTints({
|
||||
primary: COLORS_PROD.COLOR_PRIMARY,
|
||||
secondary: COLORS_PROD.COLOR_SECONDARY,
|
||||
tertiarty: COLORS_PROD.COLOR_TERTIARTY,
|
||||
danger: COLORS_PROD.COLOR_DANGER,
|
||||
primary: COLORS.COLOR_PRIMARY,
|
||||
secondary: COLORS.COLOR_SECONDARY,
|
||||
tertiarty: COLORS.COLOR_TERTIARTY,
|
||||
danger: COLORS.COLOR_DANGER,
|
||||
});
|
||||
|
||||
const config: Config = {
|
||||
@ -19,9 +19,9 @@ const config: Config = {
|
||||
theme: {
|
||||
// extend: {
|
||||
// colors: {
|
||||
// primary: COLORS_PROD.COLOR_PRIMARY,
|
||||
// secondary: COLORS_PROD.COLOR_SECONDARY,
|
||||
// tertiarty: COLORS_PROD.COLOR_TERTIARTY,
|
||||
// primary: COLORS.COLOR_PRIMARY,
|
||||
// secondary: COLORS.COLOR_SECONDARY,
|
||||
// tertiarty: COLORS.COLOR_TERTIARTY,
|
||||
// },
|
||||
// },
|
||||
},
|
||||
|
||||
@ -5922,3 +5922,8 @@ yocto-queue@^0.1.0:
|
||||
version "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:
|
||||
version "3.22.4"
|
||||
resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff"
|
||||
integrity sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user