This commit is contained in:
2026-09-10 18:54:53 +03:30
parent a308d6e039
commit e2303bcd70
8 changed files with 216 additions and 165 deletions
+13 -1
View File
@@ -1,3 +1,5 @@
import { existsSync } from 'node:fs';
import path from 'node:path';
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
@@ -6,6 +8,14 @@ import { AppModule } from './app.module';
import { applyPendingMigrations } from './apply-migrations';
import { runBundledSeed } from './run-seed';
function swaggerUiAssetsPath() {
const bundled = path.join(process.cwd(), 'runtime', 'swagger-ui');
if (existsSync(path.join(bundled, 'swagger-ui.css'))) {
return bundled;
}
return path.join(process.cwd(), 'node_modules', 'swagger-ui-dist');
}
async function bootstrap() {
if (process.env.NODE_ENV === 'production') {
await applyPendingMigrations();
@@ -44,7 +54,9 @@ async function bootstrap() {
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, swaggerConfig);
SwaggerModule.setup(`${globalPrefix}/docs`, app, document);
SwaggerModule.setup(`${globalPrefix}/docs`, app, document, {
customSwaggerUiPath: swaggerUiAssetsPath(),
});
const port = Number(process.env.PORT) || 3000;
await app.listen(port);