dox-foundation-demo node_modules/express/node_modules/connect/lib/middleware/query.js

qs

declaration
qs

    Description

    Module dependencies.

    Source

    var qs = require('qs')
      , parse = require('../utils').parseUrl;

    exports

    method
    module.exports()
    • @param: {Object}options
    • @return: {Function}

    Description

    Query:

    Automatically parse the query-string when available,
    populating the req.query object.

    Examples:

    connect()
      .use(connect.query())
      .use(function(req, res){
        res.end(JSON.stringify(req.query));
      });
    

    The options passed are provided to qs.parse function.

    Source

    module.exports = function query(options){
      return function query(req, res, next){
        if (!req.query) {
          req.query = ~req.url.indexOf('?')
            ? qs.parse(parse(req).query, options)
            : {};
        }
    
        next();
      };
    };