Search code examples
javascriptnode.jsmicroservicesnestjsmulter

How do i handle file uploads in NestJs Microservice


Do do I handle file uploads in Nestjs Microservice?

Since microservice doesn't use http req @FileInterceptor or Multer will not work. Even if there's a workaround I am unaware of it.

Kindly help


Solution

  • There is a concept called Hybrid Application in nest.js. Which enable you to listen for HTTP requests, as well as makes use of connected microservices.

    something like this :

    // Create your regular nest application.
    const app = await NestFactory.create(ApplicationModule);
    
    // Then combine it with your microservice
    const ms = app.connectMicroservice({
      transport: Transport.TCP,
      options: { host: '0.0.0.0', port: 6000 }
    });
    
    await app.startAllMicroservicesAsync();
    await app.listen(3000);