Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-query-params

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-query-params

Express.js middleware implementing the API Query Spec, converting the params to SQL or a Mongo query

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
48
increased by4.35%
Maintainers
1
Weekly downloads
 
Created
Source

Mongo Express Query Params

Express.js middleware implementing the API Query Spec, converting the query to something that can be used to look up the resource.

Installing

npm i --save express-query-params

Basic Usage

This middleware can just be plugged into your stack like so:

var express = require('express');
var queryParams = require('express-query-params');

var app = express();

app.use(queryParams());

Inside any downstream middleware, this plugin will create a parsedQuery object on the request. See the test to see how it works.

Advanced Usage

The middleware accepts a few options to make your life easier:

app.use(queryParams({

  // Function to parse integers or floats - defaults to javascript's own parseFloat
  parseNum: parseFloat,

  // Will validate dates according to this format - defaults to ISO_8601
  dateFormat: '2014-01-01',

  // Function to parse dates to the `dateFormat` variable - defaults to Moment.js
  parseDate: function() {},

  // Set this to false to disable type casting and have the output be all strings
  typeCast: true,

  // Accepts `mongodb` or `sql` - defaults to `mongodb`
  format: 'mongodb'
}));

Formats

So far, this middleware supports mongodb and sql as output formats.

In case of mongodb, the output is a javascript object that can be used to query MongoDb.

In case of sql, it will output a WHERE clause for you as a string.

Tests

mocha

Keywords

FAQs

Package last updated on 08 Nov 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc