rent_portal/src/env.js
2024-11-29 14:02:50 -06:00

57 lines
1.8 KiB
JavaScript
Executable File

import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";
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"),
AUTH_SECRET: z.string(),
AUTH_APPLE_ID: z.string(),
AUTH_APPLE_SECRET: z.string(),
APPLE_TEAM_ID: z.string(),
APPLE_KEY_ID: z.string(),
APPLE_PRIVATE_KEY_PATH: z.string(),
},
/**
* Specify your client-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars. To expose them to the client, prefix them with
* `NEXT_PUBLIC_`.
*/
client: {
// NEXT_PUBLIC_CLIENTVAR: z.string(),
},
/**
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
* middlewares) or client-side so we need to destruct manually.
*/
runtimeEnv: {
DATABASE_URL: process.env.DATABASE_URL,
NODE_ENV: process.env.NODE_ENV,
AUTH_SECRET: process.env.AUTH_SECRET,
AUTH_APPLE_ID: process.env.AUTH_APPLE_ID,
AUTH_APPLE_SECRET: process.env.AUTH_APPLE_SECRET,
APPLE_TEAM_ID: process.env.APPLE_TEAM_ID,
APPLE_KEY_ID: process.env.APPLE_KEY_ID,
APPLE_PRIVATE_KEY_PATH: process.env.APPLE_PRIVATE_KEY_PATH,
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
* useful for Docker builds.
*/
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
/**
* Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
* `SOME_VAR=''` will throw an error.
*/
emptyStringAsUndefined: true,
});