Home > database >  How to create MQTT broker in NestJS 8
How to create MQTT broker in NestJS 8

Time:12-11

I'm trying to create an MQTT broker in NestJS, so I'm following the official doc here. However I have the impression that this doc is not up to date anymore because with Nest version 8 MicroserviceOptions doesn't exist so I don't know by what to replace it.

const app = await NestFactory.createMicroservice<MicroserviceOptions>(AppModule, {
  transport: Transport.MQTT,
  options: {
    url: 'mqtt://localhost:1883',
  },
});

CodePudding user response:

Have you installed @nest/microservices?

Try npm i --save @nestjs/microservices or yarn add @nestjs/microservices if you are using yarn

You should be able to import what you need

import { Transport, MicroserviceOptions } from '@nestjs/microservices';
  • Related