npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@b8n/nestjs-rapidoc

v1.0.9

Published

NestJS module for RapiDoc

Downloads

3,244

Readme

NestJS Rapidoc Module

Nest module for seamless integration with RapiDoc, designed as a drop-in replacement (almost) for the standard OpenAPI (Swagger) module.

Installation

npm i @b8n/nestjs-rapidoc

Quick Start

To set up RapiDoc with your NestJS application, follow the Nest documentation's tutorial for creating an OpenAPI (Swagger) document. Substitute the SwaggerModule with RapidocModule as illustrated in the example below:

import { RapidocModule } from '@b8n/nestjs-rapidoc';
import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  const config = new DocumentBuilder()
    .setTitle('Cats example')
    .setDescription('The cats API description')
    .setVersion('1.0')
    .addTag('cats')
    .build();
  const document = SwaggerModule.createDocument(app, config);
  RapidocModule.setup('api', app, document);

  await app.listen(3000);
}
bootstrap();

Setup Options

Customize RapiDoc module behavior by providing an options object that adheres to the RapidocCustomOptions interface. Pass this object as the fourth argument to the RapidocModule#setup method.

export interface RapidocCustomOptions {
  useGlobalPrefix?: boolean;
  rapidocOptions?: RapidocUIOptions;
  customCss?: string;
  customCssUrl?: string | string[];
  customJs?: string | string[];
  customJsStr?: string | string[];
  customFavIcon?: string;
  customRapidocAssetsPath?: string;
  customSiteTitle?: string;
  customLogo?: string;
  jsonDocumentUrl?: string;
  yamlDocumentUrl?: string;
  patchDocumentOnRequest?: <TRequest = any, TResponse = any>(req: TRequest, res: TResponse, document: OpenAPIObject) => OpenAPIObject;
}

There are slight changes compared to the SwaggerCustomOptions from the @nestjs/swagger module:

  • The addition of customRapidocAssetsPath allows overriding the path to RapiDoc static assets. Correspondingly, the customSwaggerUiPath option has been removed.
  • The swaggerUrl has been removed as it is not utilized in the RapidocModule.
  • The introduction of customLogo enables changing the default RapiDoc logo in the sidebar. It should be a URL pointing to the custom logo.
  • The validatorUrl has been removed as it is not used by RapiDoc.
  • Both the url and urls attributes have been removed since they are not utilized by RapiDoc.
  • The rapidocOptions attribute has been added to configure the RapiDoc UI. This attribute must adhere to the RapidocUIOptions interface. Essentially, this interface represents a camelCase version (e.g., sort-tags -> sortTags) of the RapiDoc attributes. Correspondingly, the swaggerOptions option has been removed.

    Note: spec-url attribute cannot be configured as the OpenAPI spec of the application is explicitly loaded into RapiDoc upon page load.

Testing

Given the strong reliance on @nestjs/swagger, testing primarily focuses on divergent aspects. To execute E2E tests, use the following command:

npm run test:e2e

For manual testing, launch the example application using:

npm start

Access the RapiDoc UI at http://localhost:9080/api-docs.

License

This module is MIT licensed.