chore: split dev and production deployment env

This commit is contained in:
湛兮
2026-06-05 12:32:10 +08:00
parent 98cea63203
commit 488df0b1ee
12 changed files with 474 additions and 26 deletions
+2
View File
@@ -55,6 +55,8 @@ export function createApp() {
return ok({
status: "ok",
environment: env.APP_ENV,
environmentLabel: env.APP_ENV_LABEL,
database: "up",
now: new Date().toISOString(),
});
+7 -1
View File
@@ -7,6 +7,8 @@ const envSchema = z.object({
NODE_ENV: z
.enum(["local", "development", "test", "production"])
.default("development"),
APP_ENV: z.enum(["local", "development", "test", "production"]).optional(),
APP_ENV_LABEL: z.string().min(1).optional(),
PORT: z.coerce.number().int().positive().default(3000),
DB_HOST: z.string().min(1),
@@ -30,4 +32,8 @@ if (!result.success) {
}
// 其他模块只从 env 读取已校验过的值,不再直接访问 process.env。
export const env = result.data;
export const env = {
...result.data,
APP_ENV: result.data.APP_ENV ?? result.data.NODE_ENV,
APP_ENV_LABEL: result.data.APP_ENV_LABEL ?? result.data.NODE_ENV
};