feat(guild): fail fast when center auth env is missing
This commit is contained in:
16
src/main.ts
16
src/main.ts
@@ -6,7 +6,23 @@ import { AppModule } from './app.module';
|
||||
import { createRequestContextMiddleware } from './common/request-context.middleware';
|
||||
import { MetricsService } from './common/metrics.service';
|
||||
|
||||
function requireEnv(name: string): string {
|
||||
const value = process.env[name];
|
||||
if (!value || value.trim() === '') {
|
||||
throw new Error(`Missing required env: ${name}`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function validateEnv(): void {
|
||||
requireEnv('CENTER_BASE_URL');
|
||||
requireEnv('CENTER_API_KEY');
|
||||
requireEnv('GUILD_NODE_ID');
|
||||
}
|
||||
|
||||
async function bootstrap() {
|
||||
validateEnv();
|
||||
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.setGlobalPrefix('api');
|
||||
const metrics = app.get(MetricsService);
|
||||
|
||||
Reference in New Issue
Block a user