Redningsselskapet / nestjs-plugins

Plugins for NestJS framework
ISC License
27 stars 22 forks source link

Support for NATS Websockets? #47

Open Nathan-Bernardo opened 1 year ago

Nathan-Bernardo commented 1 year ago

Is your feature request related to a problem? Please describe. The current implementation allows us to easily connect to Nats Jetstream, but currently unable to connect Nats Jetstream with a web socket connection (e.g. ws://localhost:8888).

Describe the solution you'd like It would be nice to be able to connect to Nats Jetstream with web socket support.

async function bootstrap() {
  const options: CustomStrategy = {
    strategy: new NatsJetStreamServer({
      connectionOptions: {
        servers: 'ws://localhost:8888',
        name: 'artifact-listener',
      },
      consumerOptions: {
        deliverGroup: 'artifact-group',
        durable: 'artifact-durable',
        deliverTo: 'artifact-messages',
        manualAck: true,
      },
      streamConfig: {
        name: 'BUILD',
        subjects: ['task.*', 'artifact.*'],
      },
    }),
  };

  const app = await NestFactory.create(AppModule);

  const microservice = app.connectMicroservice(options);
  microservice.listen();
  await app.listen(4000);
}
bootstrap();