Gathering detailed insights and metrics for @webundsoehne/nest-fastify-file-upload
Gathering detailed insights and metrics for @webundsoehne/nest-fastify-file-upload
Gathering detailed insights and metrics for @webundsoehne/nest-fastify-file-upload
Gathering detailed insights and metrics for @webundsoehne/nest-fastify-file-upload
npm install @webundsoehne/nest-fastify-file-upload
Typescript
Module System
Min. Node Version
Node Version
NPM Version
69.7
Supply Chain
95.2
Quality
77.6
Maintenance
100
Vulnerability
99.6
License
Total Downloads
153,099
Last Day
61
Last Week
2,186
Last Month
7,724
Last Year
74,071
Minified
Minified + Gzipped
Latest Version
2.3.1
Package Id
@webundsoehne/nest-fastify-file-upload@2.3.1
Unpacked Size
149.25 kB
Size
45.09 kB
File Count
54
NPM Version
10.8.2
Node Version
20.18.3
Published on
Feb 28, 2025
Cumulative downloads
Total Downloads
Last Day
29.8%
61
Compared to previous day
Last Week
41.5%
2,186
Compared to previous week
Last Month
20.3%
7,724
Compared to previous month
Last Year
65.8%
74,071
Compared to previous year
1
4
Compatibile with NestJS 7-11 and Fastify 3-5.
Install to your project:
npm i @webundsoehne/nest-fastify-file-upload
Configure your NestApplication to use the correct body parser.
Install npm i @fastify/multipart
as multipart body parser.
Register fastifyMultipart
in your root application after creation:
1import { NestFactory } from '@nestjs/core' 2import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify' 3import { fastifyMultipart } from '@fastify/multipart' 4 5import { AppModule } from './app.module' 6 7async function bootstrap (): Promise<void> { 8 const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter()) 9 10 await app.register(fastifyMultipart) 11 12 await app.listen(3000) 13} 14
Register contentParser
in your root application after creation:
1import { NestFactory } from '@nestjs/core' 2import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify' 3import { contentParser } from 'fastify-multer' 4 5import { AppModule } from './app.module' 6 7async function bootstrap (): Promise<void> { 8 const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter()) 9 10 await app.register(contentParser) 11 12 await app.listen(3000) 13} 14 15bootstrap()
Use it like the official NestJS package for Express in your controllers:
1@Post('upload') 2@UseInterceptors(FileInterceptor('file')) 3@ApiFileBody('file') 4@ApiConsumes('multipart/form-data') 5uploadFile (@UploadedFile('file') file: MulterFile): void { 6 console.log(file) 7} 8 9...
The package will export the missing Express.Multer.*
types as Multer*
.
more information: https://docs.nestjs.com/techniques/file-upload
Useful controller decorator that adds file upload functionality in Swagger.
You can specify the file key as parameter, default key is file
.
Register the MulterModule e.g. to directly upload to a specified directory.
import { Module } from '@nestjs/common'
import { AppController } from './app.controller'
import {MulterModule} from "../multer.module";
@Module({
controllers: [AppController],
imports: [
MulterModule.register({dest: './uploads'})
]
})
export class AppModule { }
more information and options: https://docs.nestjs.com/techniques/file-upload#default-options
No vulnerabilities found.
No security vulnerabilities found.