• This repository has been archived on 04/May/2020
  • Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Express middleware of Formidable that just works.

express-formidable Build Status

An Express middleware of Formidable that just works.

What are Express, Formidable, and this?

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.

Install

npm install express-formidable

How to use

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.

Option

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.

Events

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 */ }
  }
];

Error event

Unless an error event are provided by the events array parameter, it will handle by the standard next(error).

Contribute

git clone https://github.com/utatti/express-formidable.git
cd express-formidable
npm install

To lint and test:

npm test

License

MIT

More Repositories

1

kawa

A macOS input source switcher with user-defined shortcuts.
Swift
1,369
star
2

pen

We need a better Markdown previewer.
JavaScript
326
star
3

react-render-html

Render HTML as React element, possibly replacing dangerouslySetInnerHTML
JavaScript
216
star
4

lens.ts

TypeScript Lens implementation with property proxy
TypeScript
142
star
5

kou

A minimal language compiled into wasm bytecode
TypeScript
134
star
6

tinypack

A simple TypeScript module bundler
TypeScript
63
star
7

monkey-hs

An interpreter for the Monkey programming language written in Haskell
Haskell
49
star
8

incinerator

A PoC implementation of unused code elimination in runtime
JavaScript
43
star
9

monkey-rs

An interpreter for the Monkey programming language written in Rust
Rust
37
star
10

line

Haskell SDK for the LINE APIs
Haskell
31
star
11

ClassHierarchy

Class Hierarchy with CTags for Sublime Text 2
Python
20
star
12

uit-meetup-11

UIT meetup vol.11 talk: Build you a static site generator
JavaScript
13
star
13

futaba

TensorFlow.js Example for Color Personalization
Vue
12
star
14

s-exify

Beautifier for S-expression, mainly for WAT
TypeScript
11
star
15

react-attr-converter

Convert HTML attribute names to React props
JavaScript
8
star
16

purescript-halogen-free-html

Free monad for Halogen HTML
PureScript
8
star
17

dotfiles

dotfiles for me
Vim Script
8
star
18

osx-screen-capture

Screen capture and upload tool for OS X.
Python
4
star
19

coursera-machine-learning

Programming assignments of the Machine Learning course in Coursera
MATLAB
4
star
20

mitty

A Brain*uck to WASM compiler
Brainfuck
4
star
21

suzu

SimpleHTTPServer alternative for Node.js, with no cache
JavaScript
3
star
22

MACwMP

Monadic array comprehension with meta programming in JS
JavaScript
3
star
23

smi-editor

Command-line SMI editor script only for synchronizing the subtitle!
Python
2
star
24

previewable-iterator

Previewable Iterable/Iterator for JavaScript/TypeScript
TypeScript
2
star
25

lint-webpack-plugin

A webpack plugin to run custom lint shell command
JavaScript
2
star
26

touhou-css

A CSS practice with Touhou
CSS
2
star
27

evernote2bitly

import evernote enex file format bookmarks into bitly
Python
1
star
28

bookmark

A simple bookmark script for me and you.
1
star
29

safari-imgur

DIY Safari Extension to upload images to Imgur
JavaScript
1
star
30

shogi-ui

A collection of HTML, CSS and JS for Shogi (将棋) UI on Web.
JavaScript
1
star
31

chess

A chess server
Go
1
star
32

scenic

See great pictures with your friends!
JavaScript
1
star
33

game-of-life

Conway's Game of Life with CoffeeScript
CoffeeScript
1
star
34

mahjong-statistics

django powered mahjong statistics
Python
1
star
35

euler

A Haskell adventure into Project Euler
Haskell
1
star
36

typed-styled-components

TypeScript + styled-components in a simple way
TypeScript
1
star
37

soramaru

A Twitter list viewer for images
JavaScript
1
star