fix bug
This commit is contained in:
+13
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user