@lcdev/upload
v0.2.1
Published
Simple uploading middleware on multer
Downloads
4
Keywords
Readme
Upload
Really barebones layer on top of multer, reducing the common boilerplate when adding image uploading.
yarn add @lcdev/upload@VERSION
import { uploadImage, Uploaded } from '@lcdev/upload';
// later, in your route
route({
path: '/profile/image/upload',
method: HttpMethod.POST,
middleware: [
// you can call uploadImage(config) earlier if you want to share settings
uploadImage()('image'),
],
async action(ctx) {
const { file } = ctx.req as Uploaded;
if (!file) throw err(400, 'No file was included');
const { buffer, mimetype, originalname } = file;
// do stuff!
},
})
Zero config for image uploading, but the default export gives you control like multer does.