简体   繁体   中英

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:

在此处输入图像描述

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM