feat(gateway): include production Telegram user gateway

Version the NestJS TDLib gateway with Docker deployment, migrations, automated tests and platform integration documentation while excluding all account sessions, credentials, runtime databases and backups.
This commit is contained in:
wmq
2026-08-01 18:38:20 +08:00
parent af49d22ca7
commit 06112602ec
142 changed files with 23107 additions and 7 deletions
+54
View File
@@ -0,0 +1,54 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { AllExceptionsFilter } from './common/filters/all-exceptions.filter';
import { ResponseInterceptor } from './common/interceptors/response.interceptor';
import { RequestIdInterceptor } from './common/interceptors/request-id.interceptor';
import { ValidationPipe } from './common/pipes/validation.pipe';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { Logger } from '@nestjs/common';
import helmet from 'helmet';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const logger = new Logger('Bootstrap');
app.use(helmet());
const configuredOrigins = process.env.CORS_ORIGINS
?.split(',')
.map((origin) => origin.trim())
.filter(Boolean);
app.enableCors({
origin:
configuredOrigins?.length
? configuredOrigins
: process.env.NODE_ENV === 'production'
? false
: true,
credentials: true,
});
app.enableShutdownHooks();
app.setGlobalPrefix('api');
app.useGlobalFilters(new AllExceptionsFilter());
app.useGlobalInterceptors(new RequestIdInterceptor(), new ResponseInterceptor());
app.useGlobalPipes(new ValidationPipe());
// Swagger
const config = new DocumentBuilder()
.setTitle('Telegram User Gateway API')
.setDescription('REST API for managing Telegram user accounts via TDLib')
.setVersion('1.0')
.addBearerAuth()
.addApiKey({ type: 'apiKey', name: 'x-tenant-id', in: 'header' }, 'tenant-id')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api/docs', app, document);
const port = process.env.PORT || 3000;
await app.listen(port);
logger.log(`Application running on http://localhost:${port}`);
logger.log(`Swagger docs at http://localhost:${port}/api/docs`);
}
bootstrap();