0.2.1 • Published 1 year ago

@lcdev/upload v0.2.1

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
1 year ago

Upload

npm.io npm.io

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.

0.2.1

1 year ago

0.2.0

1 year ago