Files
penx/server/env.js
2024-08-05 10:06:02 +08:00

23 lines
599 B
JavaScript

// @ts-check
/**
* This file is included in `/next.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')
/*eslint sort-keys: "error"*/
const envSchema = z.object({
NODE_ENV: z.enum(['development', 'test', 'production']),
})
const env = envSchema.safeParse(process.env)
if (!env.success) {
throw new Error(
'❌ Invalid environment variables: ' +
JSON.stringify(env.error.format(), null, 4),
)
}
module.exports.env = env.data