Skip to content

Commit de09f99

Browse files
committed
chore: Refactor swagger.ts for improved readability and maintainability
1 parent 49e1ae0 commit de09f99

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

src/swagger.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { SwaggerTheme, SwaggerThemeNameEnum } from 'swagger-themes';
1010
export default async function swagger(app: NestExpressApplication) {
1111
const config = app.get<ConfigService>(ConfigService);
1212
const pkg = JSON.parse(readFileSync('package.json', 'utf-8'));
13+
1314
const build = new DocumentBuilder()
1415
.setTitle(pkg.name)
1516
.setDescription(pkg.description)
@@ -18,8 +19,10 @@ export default async function swagger(app: NestExpressApplication) {
1819
.addSecurityRequirements('jwt')
1920

2021
.build();
22+
2123
const document = SwaggerModule.createDocument(app, build);
2224
const theme = new SwaggerTheme();
25+
2326
SwaggerModule.setup(config.get<string>('swagger.path'), app, document, {
2427
...config.get<SwaggerCustomOptions>('swagger.options'),
2528
explorer: false,
@@ -30,31 +33,5 @@ export default async function swagger(app: NestExpressApplication) {
3033
customCss: theme.getBuffer(SwaggerThemeNameEnum.ONE_DARK),
3134
});
3235

33-
// await RedocModule.setup('swagger', app as any, document, {
34-
// title: 'Hello Nest',
35-
// logo: {
36-
// url: 'https://redocly.github.io/redoc/petstore-logo.png',
37-
// backgroundColor: '#F0F0F0',
38-
// altText: 'PetStore logo'
39-
// },
40-
// sortPropsAlphabetically: true,
41-
// hideDownloadButton: false,
42-
// hideHostname: false,
43-
// // auth: {
44-
// // enabled: true,
45-
// // user: 'admin',
46-
// // password: '123'
47-
// // },
48-
// // tagGroups: [
49-
// // {
50-
// // name: 'Core resources',
51-
// // tags: ['cats'],
52-
// // },
53-
// // ],
54-
// })
55-
// Logger.warn(`Swagger is READY on <http://`)
56-
// const router = app.getHttpAdapter().getInstance()._router
57-
// console.log('app', router.stack[router.stack.length - 1])
58-
5936
app.getHttpAdapter().get(config.get<string>('swagger.api'), (_, res: Response) => res.json(document));
6037
}

0 commit comments

Comments
 (0)