Skip to content

Commit

Permalink
feat: loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannfleurydev committed Sep 29, 2023
1 parent 393147e commit 2c4891e
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ AUTH_SECRET="Replace me with `openssl rand -base64 32` generated secret"
# EMAILS
EMAIL_SERVER="smtp://username:password@localhost:1025"
EMAIL_FROM="Start UI <noreply@example.com>"

LOGGER_LEVEL="info"
LOGGER_PRETTY="true"
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@
"@trpc/react-query": "10.38.5",
"@trpc/server": "10.38.5",
"bcrypt": "5.1.1",
"colorette": "2.0.20",
"dayjs": "1.11.10",
"framer-motion": "10.16.4",
"i18next": "23.5.1",
"jsonwebtoken": "9.0.2",
"lodash": "4.17.21",
"next": "13.5.3",
"nodemailer": "6.9.5",
"pino": "8.15.1",
"pino-pretty": "10.2.0",
"react": "18.2.0",
"react-currency-input-field": "3.6.11",
"react-day-picker": "7.4.10",
Expand Down
141 changes: 134 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,30 @@
import { createEnv } from '@t3-oss/env-nextjs';
import { z } from 'zod';

const zNodeEnv = z
.enum(['development', 'test', 'production'])
.default('development');

export const env = createEnv({
/**
* Specify your server-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars.
*/
server: {
DATABASE_URL: z.string().url(),
NODE_ENV: z
.enum(['development', 'test', 'production'])
.default('development'),
NODE_ENV: zNodeEnv,

AUTH_SECRET: z.string(),

EMAIL_SERVER: z.string().url(),
EMAIL_FROM: z.string(),
LOGGER_LEVEL: z
.enum(['debug', 'info', 'warn', 'error', 'fatal'])
.default(process.env.NODE_ENV === 'production' ? 'error' : 'info'),
LOGGER_PRETTY: z
.enum(['true', 'false'])
.default(process.env.NODE_ENV === 'production' ? 'false' : 'true')
.transform((value) => value === 'true'),
},

/**
Expand All @@ -31,6 +40,7 @@ export const env = createEnv({

NEXT_PUBLIC_DEV_ENV_NAME: z.string().optional(),
NEXT_PUBLIC_DEV_ENV_COLOR_SCHEME: z.string().optional(),
NEXT_PUBLIC_NODE_ENV: zNodeEnv,
},

/**
Expand All @@ -43,11 +53,15 @@ export const env = createEnv({
AUTH_SECRET: process.env.AUTH_SECRET,
EMAIL_FROM: process.env.EMAIL_FROM,
EMAIL_SERVER: process.env.EMAIL_SERVER,
LOGGER_LEVEL: process.env.LOGGER_LEVEL,
LOGGER_PRETTY: process.env.LOGGER_PRETTY,

NEXT_PUBLIC_BASE_URL: process.env.NEXT_PUBLIC_BASE_URL,
NEXT_PUBLIC_DEV_ENV_COLOR_SCHEME:
process.env.NEXT_PUBLIC_DEV_ENV_COLOR_SCHEME,
NEXT_PUBLIC_DEV_ENV_NAME: process.env.NEXT_PUBLIC_DEV_ENV_NAME,
NEXT_PUBLIC_IS_DEMO: process.env.NEXT_PUBLIC_IS_DEMO,
NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV,
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
Expand Down
Loading

0 comments on commit 2c4891e

Please sign in to comment.