@jginsburgn/formidable-middleware
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

A formidable Proxy Mountable as a Middleware

A proxy for formidable that acts as an Express middleware.

Use as follows:

import express, {
  Express,
  Response,
} from "express";
import {
  FormidableMiddleware,
  FormidableMiddlewareRequest,
} from "@jginsburgn/formidable-middleware";

const app: Express = express();
const formidableFormConfiguration = {
  maxFileSize: 10 * 1024 ** 3 // 10 GB
};

app.post("/", FormidableMiddleware(formidableFormConfiguration), (req: FormidableMiddlewareRequest, res: Response) => {
  for (const file of req.body.files) {
    // Do what you wish with the file...
  }
  for (const field of req.body.fields) {
    // Do what you wish with the field...
  }
});

app.listen(80, "0.0.0.0");

Package Sidebar

Install

npm i @jginsburgn/formidable-middleware

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

6.53 kB

Total Files

5

Last publish

Collaborators

  • jginsburgn