chore: sync changes for v0.1.1
This commit is contained in:
@@ -75,6 +75,12 @@ export interface AppConfig {
|
||||
limit: number;
|
||||
};
|
||||
|
||||
// 启动健康检查配置
|
||||
health: {
|
||||
startupCheckEnabled: boolean;
|
||||
startupTimeoutMs: number;
|
||||
};
|
||||
|
||||
// 第三方服务配置
|
||||
thirdParty: {
|
||||
storage: {
|
||||
@@ -106,8 +112,8 @@ const defaultConfig: AppConfig = {
|
||||
database: {
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
username: 'root',
|
||||
password: '123456',
|
||||
username: 'wwjcloud',
|
||||
password: 'wwjcloud',
|
||||
database: 'wwjcloud',
|
||||
synchronize: false,
|
||||
logging: true,
|
||||
@@ -149,6 +155,10 @@ const defaultConfig: AppConfig = {
|
||||
ttl: 60,
|
||||
limit: 100,
|
||||
},
|
||||
health: {
|
||||
startupCheckEnabled: true,
|
||||
startupTimeoutMs: 5000,
|
||||
},
|
||||
thirdParty: {
|
||||
storage: {
|
||||
provider: 'local',
|
||||
@@ -223,6 +233,13 @@ function loadFromEnv(): Partial<AppConfig> {
|
||||
ttl: parseInt(process.env.THROTTLE_TTL || String(defaultConfig.throttle.ttl), 10),
|
||||
limit: parseInt(process.env.THROTTLE_LIMIT || String(defaultConfig.throttle.limit), 10),
|
||||
},
|
||||
health: {
|
||||
startupCheckEnabled: (process.env.STARTUP_HEALTH_CHECK || 'true').toLowerCase() !== 'false',
|
||||
startupTimeoutMs: parseInt(
|
||||
process.env.STARTUP_HEALTH_TIMEOUT_MS || String(defaultConfig.health.startupTimeoutMs),
|
||||
10,
|
||||
),
|
||||
},
|
||||
thirdParty: {
|
||||
storage: {
|
||||
provider: process.env.STORAGE_PROVIDER || defaultConfig.thirdParty.storage.provider,
|
||||
@@ -256,6 +273,7 @@ function mergeConfig(defaultConfig: AppConfig, envConfig: Partial<AppConfig>): A
|
||||
logging: { ...defaultConfig.logging, ...envConfig.logging },
|
||||
upload: { ...defaultConfig.upload, ...envConfig.upload },
|
||||
throttle: { ...defaultConfig.throttle, ...envConfig.throttle },
|
||||
health: { ...defaultConfig.health, ...envConfig.health },
|
||||
thirdParty: {
|
||||
storage: { ...defaultConfig.thirdParty.storage, ...envConfig.thirdParty?.storage },
|
||||
payment: { ...defaultConfig.thirdParty.payment, ...envConfig.thirdParty?.payment },
|
||||
@@ -323,6 +341,11 @@ export const config = {
|
||||
return appConfig.throttle;
|
||||
},
|
||||
|
||||
// 获取健康检查配置
|
||||
getHealth() {
|
||||
return appConfig.health;
|
||||
},
|
||||
|
||||
// 获取第三方服务配置
|
||||
getThirdParty() {
|
||||
return appConfig.thirdParty;
|
||||
|
||||
@@ -6,6 +6,8 @@ import { ConfigValidationService } from '../services/configValidationService';
|
||||
import { DynamicConfigService } from '../services/dynamicConfigService';
|
||||
import { DocsNavigationController } from '../controllers/docsNavigationController';
|
||||
import { appConfig } from './appConfig';
|
||||
import { SwaggerController } from '../modules/swagger/swaggerController';
|
||||
import { SwaggerService } from '../modules/swagger/swaggerService';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -15,11 +17,12 @@ import { appConfig } from './appConfig';
|
||||
envFilePath: ['.env.local', '.env.development', '.env.production', '.env'],
|
||||
}),
|
||||
],
|
||||
controllers: [ConfigController, DocsNavigationController],
|
||||
controllers: [ConfigController, DocsNavigationController, SwaggerController],
|
||||
providers: [
|
||||
ConfigCenterService,
|
||||
ConfigValidationService,
|
||||
DynamicConfigService,
|
||||
SwaggerService,
|
||||
{
|
||||
provide: 'APP_CONFIG',
|
||||
useValue: appConfig,
|
||||
|
||||
Reference in New Issue
Block a user