Daniil Sinelnik
Daniil Sinelnik

Reputation: 324

How to use platform-express and platform-fastify together

My purpose is to upload file via nestjs application using package @types/multer.

But the problem is that official docs says:

enter image description here

As soon as i started to write my application, i decided to use FastifyAdaptor as primary engine.

const app = await NestFactory.create<NestFastifyApplication>(
    BackendAdminModule,
    new FastifyAdapter({
      logger: true
    }))

And all my routes working on fastify engine.

Is there any possible solution to use both platforms(fastify and express)

Or instanciate somehow for 1 particular route an express engine to make it possible to upload and validate file/files via @types/multer package?

Any possible solutions that might be useful in my case, thanks in advance!

Upvotes: 0

Views: 654

Answers (1)

Jay McDoniel
Jay McDoniel

Reputation: 70412

As of 7/23/2022 I've published @nest-lab/fastify-multer. You should be able to use it exactly like the MulterModule from NestJS just make sure you import FastifyMulterModule somewhere to register the content parser for multipart/form-data. Then you can use the FileInterceptor from @nest-lab/fastify-multer and get the same file parsing as you would in express.

Upvotes: 1

Related Questions