Nestjs Asyncapi Save

NestJS AsyncAPI module - generate the documentation of your event-based services using decorators

Project README




AsyncApi module for Nest.

Generate AsyncApi documentation (for event-based services, like websockets) in a similar to nestjs/swagger fashion.

Documentation example


full installation (with chromium)

$ npm i --save nestjs-asyncapi

nestjs-async api package doesn't require chromium (which is required by asyncapi lib), so u can skip chromium installation by setting PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true environment variable.

$ PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm i --save nestjs-asyncapi

Quick Start

Include AsyncApi initialization into your bootstrap function.

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

    const asyncApiOptions = new AsyncApiDocumentBuilder()
        .setDescription('Feline server description here')
        .addSecurity('user-password', {type: 'userPassword'})
        .addServer('feline-ws', {
            url: 'ws://localhost:3000',
            protocol: '',

    const asyncapiDocument = await AsyncApiModule.createDocument(app, asyncApiOptions);
    await AsyncApiModule.setup(docRelPath, app, asyncapiDocument);

    // other bootstrap procedures here

    return app.listen(3000);

AsyncApi module explores Controllers & WebSocketGateway by default. In most cases you won't need to add extra annotation, but if you need to define asyncApi operations in a class that's not a controller or gateway use the AsyncApi class decorator.

Mark pub/sub methods via AsyncApiPub or AsyncApiSub decorators

class CreateFelineDto {
    demo: string;

class DemoController {
        channel: 'create/feline',
        message: {
            payload: CreateFelineDto
    async createFeline() {
        // logic here

        channel: 'create/feline',
        message: {
            payload: CreateFelineDto
    async createFeline() {
        // logic here

For more detailed examples please check out sample app.

Do you use this library and like it? Don't be shy to give it a star on github
Open Source Agenda is not affiliated with "Nestjs Asyncapi" Project. README Source: flamewow/nestjs-asyncapi
Open Issues
Last Commit
3 weeks ago

Open Source Agenda Badge

Open Source Agenda Rating