Files
lingxi/apps/api/src/main.ts
T
Stev_Wang 23067edb8f feat(api): 搭建 API 与 Worker 骨架及契约基线
NestJS 11 + Fastify 统一错误体与 trace_id,/health 真实探活 DB/Redis,OpenAPI 3.1 契约含 20 个错误码;shared 包提供错误码、权限点、ULID、分页与通用 schema;worker 完成队列进程骨架。
2026-11-02 17:20:46 +08:00

25 lines
716 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'reflect-metadata';
import { Logger } from 'nestjs-pino';
import { createApp, setupOpenApi } from './bootstrap';
import { loadDotenv } from './config/load-dotenv';
async function bootstrap(): Promise<void> {
loadDotenv();
const { app, config } = await createApp();
await app.init();
setupOpenApi(app, config);
await app.listen(config.port, config.host);
const logger = app.get(Logger);
logger.log(`灵犀 API 已启动:http://${config.host}:${config.port}(文档 /api/docs)`);
}
void bootstrap().catch((error: unknown) => {
process.stderr.write(
`API 启动失败:${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`,
);
process.exitCode = 1;
});