GithubHelp home page GithubHelp logo

yahoo / express-normalized Goto Github PK

View Code? Open in Web Editor NEW
1.0 9.0 1.0 4 KB

Similar to PHP's $_REQUEST object, this mixes the GET vars and POST vars into a normalized Object

License: MIT License

JavaScript 100.00%

express-normalized's Introduction

express-normalized

Similar to PHP's $_REQUEST object, this mixes the GET vars and POST vars into a normalized Object always choosing POST over GET.

By default it creates a new Object, then walks the req.query and adds the key/value to it, then it will walk the req.body and do the same. It will always use the POST version of the value if it is available. It will then add this new Object to the req as normalized. See the configuration section below for changing these values.

npm Version Build Status

usage

var app = express(),
    normalized = require('express-normalized');

//Add your normalize handlers for get/post here
//busboy, body-parser, etc

app.use(normalized());

//Then in your app:

function(req, res) {
    console.log(req.normalized);
}

configuration

You can configure where it get's the GET & POST from as well as the namespace that it applies it to:

var app = express(),
    normalized = require('express-normalized');

//Add your normalize handlers for get/post here
//busboy, body-parser, etc

//Maybe you are using a custom variable parser and it uses
// queries as get vars and bodies as post vars
// and you want it to populate the req.normal variable

app.use(normalized({
    base: 'normal',
    get: 'queries',
    post: 'bodies'
}));

//Then in your app:

function(req, res) {
    console.log(req.normal);
}

express-normalized's People

Contributors

davglass avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

bkeepers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.