You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
import { z } from "zod";
|
|
|
|
/**
|
|
* Zod schema for all environment variables used across the project.
|
|
*
|
|
* Every `process.env.X` access should be replaced by importing `env` from
|
|
* this package and using the typed, validated value.
|
|
*
|
|
* To add a new env var:
|
|
* 1. Add it to this schema with the correct type, default, and validation.
|
|
* 2. The typed `env` object is auto-generated from the schema's output.
|
|
*/
|
|
|
|
export const envSchema = z.object({
|
|
// ── Database ──
|
|
DATABASE_URL: z.string().min(1, "DATABASE_URL is required"),
|
|
|
|
// ── Node / Runtime ──
|
|
NODE_ENV: z
|
|
.enum(["development", "production", "test"])
|
|
.default("development"),
|
|
|
|
// ── Logging (logger package) ──
|
|
LOG_MAX_SIZE: z.coerce.number().int().positive().default(10 * 1024 * 1024), // 10 MB
|
|
LOG_MAX_BACKUPS: z.coerce.number().int().nonnegative().default(5),
|
|
|
|
// ── Static file serving ──
|
|
STATIC_DIR: z.string().default("static"),
|
|
UPLOAD_SUBDIR: z.string().default("upload"),
|
|
|
|
// ── Scheduler ──
|
|
SCHEDULER_MAX_CONCURRENCY: z.coerce.number().int().positive().default(5),
|
|
SCHEDULER_LOG_RETENTION_DAYS: z.coerce.number().int().positive().default(30),
|
|
|
|
// ── App ──
|
|
APP_URL: z.string().min(1, "APP_URL is required"),
|
|
NITRO_PORT: z.coerce.number().int().positive(),
|
|
|
|
// ── OAuth: GitHub ──
|
|
GITHUB_CLIENT_ID: z.string().default(""),
|
|
GITHUB_CLIENT_SECRET: z.string().default(""),
|
|
|
|
// ── OAuth: Gitea ──
|
|
GITEA_CLIENT_ID: z.string().default(""),
|
|
GITEA_CLIENT_SECRET: z.string().default(""),
|
|
GITEA_URL: z.string().default(""),
|
|
|
|
// ── Bootstrap (seed) ──
|
|
BOOTSTRAP_ADMIN_USERNAME: z.string().optional(),
|
|
BOOTSTRAP_ADMIN_PASSWORD: z.string().optional(),
|
|
});
|
|
|
|
/** Inferred type of the parsed env object. */
|
|
export type Env = z.infer<typeof envSchema>;
|
|
|