feat(guild): fail fast when center auth env is missing
This commit is contained in:
@@ -13,3 +13,10 @@ Guild Node service for Fabric.
|
||||
- API skeleton (NestJS)
|
||||
- Chat domain models
|
||||
- Seq allocator and range query endpoints
|
||||
|
||||
## Required env (startup hard checks)
|
||||
- `CENTER_BASE_URL`
|
||||
- `CENTER_API_KEY`
|
||||
- `GUILD_NODE_ID`
|
||||
|
||||
If any of the above is missing, service startup fails immediately.
|
||||
|
||||
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