β»
Multer Express Middleware A weekend project that will help you to easily setup multer with just a middleware.
π₯
Usage Installing the module.
yarn add multer-express-middleware
Using the middleware with Express.
const app = require('express')()
const imageStore = require('multer-express-middleware')
app.use("/api", imageStore({
// Folder where you would like to save files or images (required)
destination: "uploads",
// Property where you would like to set selected image or file while uploading form frontend...
imageProperty: "image",
customize: {
upload: {
// field you want to fill while posting an api request... ex "imageFolderName"
folderProperty: "folder",
// folder to save image or file
subFolderProperty: "subfolder"
// Api path for uploading image or file
path: "/image/upload"
},
delete: {
// Property where you would to set image path while giving an post request.
filePathProperty: "imagePath",
// API path for deleting image or file
path: '/image/delete'
}
},
// Custom middlewares, if you wish... ;)
middlewares: [isSignedIn, isAuthenticated]
}))
TODO: Need to add some more stuff over here...
π€
Why made this? Just wanted to make something that I could use in all of my MERN Projects. It's a big pain recreating this everytime I start a new project.
Author
- Website: https://piyushsuthar.codes
- Twitter: @piyushsthr
- Github: @piyushsuthar
- LinkedIn: @piyushsthr
π€ Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Show your support
Give a