@@ -55,34 +55,42 @@ Example the path is `/docs
5555
5656Here's an example of how to use this package:
5757
58- ## nodejs-api-doc with @nest/swagger
58+ ## nodejs-api-doc with Nest Fastify + @nest/swagger
5959
6060Step:
6161
62621 . Modify your ` src/main.ts `
63632 . Create a swagger config with ` new DocumentBuilder() `
64643 . Generate open api document object with ` SwaggerModule.createDocument(app, config) `
65- 4 . Setup nodejs-api-doc with ` new NodejsApiDoc `
65+ 4 . Setup nodejs-api-doc with ` new NestApiDoc `
66665 . Start nodejs-api-doc with ` nodejsApiDoc.start() `
6767
6868``` typescript
69- // swagger
70- const config = new DocumentBuilder ()
71- .setTitle (' Node.js API Docs' )
72- .setDescription (' This API provides ...' )
73- .setVersion (' 0.0.1' )
74- .build ()
75- const document = SwaggerModule .createDocument (app , config )
76-
77- // nodejs-api-doc
78- const nodejsApiDoc = new NodejsApiDoc (app , document , {
79- defaultUI: ' redoc' ,
80- customPath: ' /api-docs' ,
81- })
82- nodejsApiDoc .start ()
83-
84- // Run the nestjs
85- await app .listen (8080 , ' 0.0.0.0' )
69+ import { NestApiDoc } from ' @didik-mulyadi/nodejs-api-doc'
70+
71+ async function bootstrap() {
72+ const app = await NestFactory .create <NestFastifyApplication >(
73+ AppModule ,
74+ new FastifyAdapter ()
75+ )
76+ // swagger
77+ const config = new DocumentBuilder ()
78+ .setTitle (' Node.js API Docs' )
79+ .setDescription (' This API provides ...' )
80+ .setVersion (' 0.0.1' )
81+ .build ()
82+ const document = SwaggerModule .createDocument (app , config )
83+
84+ // nodejs-api-doc
85+ const nestApiDoc = new NestApiDoc (app , document , {
86+ defaultUI: ' stoplight' ,
87+ customPath: ' /docs' ,
88+ })
89+ nestApiDoc .start ()
90+
91+ // Run the nestjs
92+ await app .listen (8080 , ' 0.0.0.0' )
93+ }
8694```
8795
8896## Configuration options ⚙️
@@ -92,7 +100,7 @@ await app.listen(8080, '0.0.0.0')
92100#### Nest.JS Fastify Helmet
93101
94102``` typescript
95- import { NodejsApiDoc , helmetConfig } from ' @didik-mulyadi/nodejs-api-doc' ;
103+ import { NestApiDoc , helmetConfig } from ' @didik-mulyadi/nodejs-api-doc' ;
96104
97105async function bootstrap() {
98106 ...
0 commit comments