From 02a69f3db2f4a33bf3d91c5144ef9babfa53b8c9 Mon Sep 17 00:00:00 2001 From: SepehrYahyaee <7heycallmegray@gmail.com> Date: Sun, 31 May 2026 15:03:46 +0330 Subject: [PATCH] Fixed Swagger ui in prod --- src/main.ts | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main.ts b/src/main.ts index 8c6b4b4..5ae0c6c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -54,38 +54,38 @@ async function bootstrap() { return challenge(); } }); - } - const config = new DocumentBuilder() - .setTitle("yara724-backend") - .setVersion("1.0.0") - .addServer(process.env.BASE_URL_DEV + "/api") - .addServer("http://192.168.20.170:9001") - .addServer("https://user.yara724.com/api") - .addServer("http://localhost:9001") - .addBearerAuth() - .build(); + const config = new DocumentBuilder() + .setTitle("yara724-backend") + .setVersion("1.0.0") + .addServer(process.env.BASE_URL_DEV + "/api") + .addServer("http://192.168.20.170:9001") + .addServer("https://user.yara724.com/api") + .addServer("http://localhost:9001") + .addBearerAuth() + .build(); - const docs = SwaggerModule.createDocument(app, config); + const docs = SwaggerModule.createDocument(app, config); - SwaggerModule.setup("docs", app, docs, { - swaggerOptions: { - persistAuthorization: true, - docExpansion: "none", - ui: isDevelopment ? true : false, - raw: isDevelopment ? true : false, - tagsSorter: (a: string, b: string) => { - const priority: Record = { - user: 0, - actor: 1, - }; - const pa = priority[a] ?? 100; - const pb = priority[b] ?? 100; - if (pa !== pb) return pa - pb; - return a.localeCompare(b); + SwaggerModule.setup("docs", app, docs, { + swaggerOptions: { + persistAuthorization: true, + docExpansion: "none", + ui: isDevelopment ? true : false, + raw: isDevelopment ? true : false, + tagsSorter: (a: string, b: string) => { + const priority: Record = { + user: 0, + actor: 1, + }; + const pa = priority[a] ?? 100; + const pb = priority[b] ?? 100; + if (pa !== pb) return pa - pb; + return a.localeCompare(b); + }, }, - }, - }); + }); + } await app.listen(process.env.PORT); }