1
0
forked from Yara724/api

Fixed Swagger ui in prod

This commit is contained in:
SepehrYahyaee
2026-05-31 15:03:46 +03:30
parent 2b7192151d
commit 02a69f3db2

View File

@@ -54,38 +54,38 @@ async function bootstrap() {
return challenge(); return challenge();
} }
}); });
}
const config = new DocumentBuilder() const config = new DocumentBuilder()
.setTitle("yara724-backend") .setTitle("yara724-backend")
.setVersion("1.0.0") .setVersion("1.0.0")
.addServer(process.env.BASE_URL_DEV + "/api") .addServer(process.env.BASE_URL_DEV + "/api")
.addServer("http://192.168.20.170:9001") .addServer("http://192.168.20.170:9001")
.addServer("https://user.yara724.com/api") .addServer("https://user.yara724.com/api")
.addServer("http://localhost:9001") .addServer("http://localhost:9001")
.addBearerAuth() .addBearerAuth()
.build(); .build();
const docs = SwaggerModule.createDocument(app, config); const docs = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("docs", app, docs, { SwaggerModule.setup("docs", app, docs, {
swaggerOptions: { swaggerOptions: {
persistAuthorization: true, persistAuthorization: true,
docExpansion: "none", docExpansion: "none",
ui: isDevelopment ? true : false, ui: isDevelopment ? true : false,
raw: isDevelopment ? true : false, raw: isDevelopment ? true : false,
tagsSorter: (a: string, b: string) => { tagsSorter: (a: string, b: string) => {
const priority: Record<string, number> = { const priority: Record<string, number> = {
user: 0, user: 0,
actor: 1, actor: 1,
}; };
const pa = priority[a] ?? 100; const pa = priority[a] ?? 100;
const pb = priority[b] ?? 100; const pb = priority[b] ?? 100;
if (pa !== pb) return pa - pb; if (pa !== pb) return pa - pb;
return a.localeCompare(b); return a.localeCompare(b);
},
}, },
}, });
}); }
await app.listen(process.env.PORT); await app.listen(process.env.PORT);
} }