chore: split dev and production deployment env
This commit is contained in:
@@ -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
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user