2968484d2d
- Money.tsx (2260行→54行): 拆分为 money/ 子目录4个组件, React.lazy二级分割 - AIAssistant.tsx (2038行→63行): 拆分为 ai-assistant/ 子目录6个组件, React.lazy二级分割 - xlsx改为动态导入, OvertimeTab从345KB降至12.7KB - api-services.ts: 请求参数 any→Record<string,unknown> - 移除前端3处console.log残留 - 后端console替换为pino logger - 前后端未使用import/变量清理 - Zod schema验证: termination/platform/special-status/work-process - 新增 leave.routes.ts, acceptance-test.routes.ts - UI组件: PageGuide, QueryError, Stepper
25 lines
803 B
TypeScript
25 lines
803 B
TypeScript
import logger from './logger'
|
|
|
|
const required = ['JWT_SECRET', 'JWT_REFRESH_SECRET', 'ENCRYPTION_KEY']
|
|
const defaults: Record<string, string> = {
|
|
JWT_SECRET: 'dev-secret',
|
|
JWT_REFRESH_SECRET: 'dev-refresh-secret',
|
|
ENCRYPTION_KEY: 'default-32-byte-encryption-key!!',
|
|
}
|
|
|
|
export function validateEnv(): void {
|
|
const missing: string[] = []
|
|
for (const key of required) {
|
|
if (!process.env[key] || process.env[key] === defaults[key]) {
|
|
missing.push(key)
|
|
}
|
|
}
|
|
if (missing.length > 0 && process.env.NODE_ENV === 'production') {
|
|
logger.fatal({ missing }, '以下环境变量未设置或使用了默认值,生产环境禁止启动')
|
|
process.exit(1)
|
|
}
|
|
if (missing.length > 0) {
|
|
logger.warn({ missing }, '以下环境变量使用了默认值,仅限开发环境')
|
|
}
|
|
}
|