Add env check and global env infer type
This commit is contained in:
parent
b881b1383f
commit
06db4e892e
15
env.ts
Normal file
15
env.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { z } from "zod";
|
||||
const envVariables = z.object({
|
||||
DATABASE_URL: z.string(),
|
||||
JWT_SECRET: z.string(),
|
||||
WS_PORT: z.string(),
|
||||
WS_HOST: z.string()
|
||||
});
|
||||
envVariables.parse(process.env);
|
||||
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface ProcessEnv extends z.infer<typeof envVariables> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3,7 +3,8 @@
|
|||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"check-env": "bun run ./env.ts",
|
||||
"dev": "bun run check-env && next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user