
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
express-formidable
Advanced tools
An Express middleware of Formidable that just works.
Express is a fast, unopinionated, minimalist web framework for Node.js.
Formidable is a Node.js module
for parsing form data, including multipart/form-data
file upload.
So, express-formidable
is something like a bridge between them,
specifically an Express middleware implementation of Formidable.
It aims to just work.
npm install express-formidable
const express = require('express');
const formidableMiddleware = require('express-formidable');
var app = express();
app.use(formidableMiddleware());
app.post('/upload', (req, res) => {
req.fields; // contains non-file fields
req.files; // contains files
});
And that's it.
express-formidable can basically parse form types Formidable can handle,
including application/x-www-form-urlencoded
, application/json
, and
multipart/form-data
.
app.use(formidableMiddleware(opts));
opts
are options which can be set to form
in Formidable. For example:
app.use(formidableMiddleware({
encoding: 'utf-8',
uploadDir: '/my/dir',
multiples: true, // req.files to be arrays of files
});
For the detail, please refer to the Formidable API.
app.use(formidableMiddleware(opts, events));
events
is an array of json with two field:
Field | Description |
---|---|
event | The event emitted by the form of formidable. A complete list of all the possible events, please refer to the Formidable Events |
action | The callback to execute. The signature is function (req, res, next, ...formidable_parameters) |
For example:
const events = [
{
event: 'fileBegin',
action: function (req, res, next, name, file) { /* your callback */ }
},
{
event: 'field',
action: function (req, res, next, name, value) { /* your callback */ }
}
];
Unless an error
event are provided by the events
array parameter, it will handle by the standard next(error)
.
git clone https://github.com/noraesae/express-formidable.git
cd express-formidable
npm install
To lint and test:
npm test
FAQs
An Express middleware of Formidable that just works.
The npm package express-formidable receives a total of 45,268 weekly downloads. As such, express-formidable popularity was classified as popular.
We found that express-formidable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.