JSPM

@didik-mulyadi/nodejs-api-doc

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 127
  • Score
    100M100P100Q101195F
  • License MIT

A template to develop NPM package with Typescript

Package Exports

  • @didik-mulyadi/nodejs-api-doc
  • @didik-mulyadi/nodejs-api-doc/package.json

Readme

⚡️@didik-mulyadi/nodejs-api-docs

A package to generate the API docs based on the open API file.


Bug report



Installation 🚀

Install @didik-mulyadi/nodejs-api-docs using pnpm/npm/yarn:

pnpm add @didik-mulyadi/nodejs-api-docs

# OR

npm install @didik-mulyadi/nodejs-api-docs

# OR

yarn add @didik-mulyadi/nodejs-api-docs

Usage 💻

Here's an example of how to use this package:

nodejs-api-doc with @nest/swagger

Step:

  1. Modify your src/main.ts
  2. Create a swagger config with new DocumentBuilder()
  3. Generate open api document object with SwaggerModule.createDocument(app, config)
  4. Setup nodejs-api-doc with new NodejsApiDoc
  5. Start nodejs-api-doc with nodejsApiDoc.start()
// swagger
const config = new DocumentBuilder()
  .setTitle('Node.js API Docs')
  .setDescription('This API provides ...')
  .setVersion('0.0.1')
  .build()
const document = SwaggerModule.createDocument(app, config)

// nodejs-api-doc
const nodejsApiDoc = new NodejsApiDoc(app, document, {
  defaultUI: 'redoc',
  customPath: '/api-docs',
})
nodejsApiDoc.start()

// Run the nestjs
await app.listen(8080, '0.0.0.0')

Configuration options ⚙️

Working with Helmet

Nest.JS Fastify Helmet

import { NodejsApiDoc, helmetConfig } from '@didik-mulyadi/nodejs-api-doc';

async function bootstrap() {
  ...
  await app.register(helmet, helmetConfig.nodeApiDocHelmetOption);
  ...
}

Bugs or Requests 🐛

If you found any issue or have a good suggestion, feel free to open an issue