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 - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

formats/sequelize.js

6

lib/index.js

@@ -12,2 +12,8 @@ const DEFAULT_OPTIONS = {

const options = { ...DEFAULT_OPTIONS, ...customOptions }
if (
options.format === 'sequelize'
&& !options.sequelizeOp
) throw new Error('Format `sequelize` requires option `sequelizeOp`')
const parser = require(`../formats/${options.format}`)(options)

@@ -14,0 +20,0 @@

2

lib/utils.js

@@ -27,2 +27,2 @@ /*

exports.trimOperators = raw => raw.replace(OPERATOR_TRIM_REGEX, '')
exports.trimOperators = raw => String(raw).replace(OPERATOR_TRIM_REGEX, '')
{
"name": "express-query-params",
"version": "1.0.2",
"version": "1.1.0",
"description": "Express.js middleware implementing the API Query Spec, converting the params to SQL or a Mongo query",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -55,3 +55,5 @@ # Express Query Params

// Accepts `mongo` or `sql` - defaults to `mongo`
/*
Accepts `mongo`, `sql` or `sequelize` - defaults to `mongo`
*/
format: 'mongo',

@@ -83,8 +85,9 @@

So far, this middleware supports `mongodb` and `sql` as output formats.
So far, this middleware supports `mongodb`, `sql` and `sequelize` 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 an object with the following props:
* `mongodb` the output is a javascript object that can be used to query MongoDb.
* `sql` it will output an object with the following props:
* `query` - this contains a tokenised query (ie. `$1` replaces raw params)
* `values` - this is an array of typecast values you can use in your query runner to coincide with the `query` prop
* `sequelize` outputs an object usable as a where clause in a Sequelize lookup

@@ -91,0 +94,0 @@ ## A Note About v1

@@ -5,3 +5,2 @@ /* global test expect */

const getQuery = require('../query')
const { DEFAULT_OPTIONS } = require('../../lib')

@@ -38,4 +37,4 @@ const correctQuery = {

test('req.query -> Mongo', () => {
const parsedQuery = mongoParser(DEFAULT_OPTIONS)(getQuery)
const parsedQuery = mongoParser({ blacklistParams: [ 'limit' ] })(getQuery)
expect(parsedQuery).toEqual(correctQuery)
})

@@ -5,3 +5,2 @@ /* global test expect */

const getQuery = require('../query')
const { DEFAULT_OPTIONS } = require('../../lib')

@@ -52,3 +51,3 @@ const correctValues = [

test('req.query -> SQL', () => {
const { query, values } = sqlParser(DEFAULT_OPTIONS)(getQuery)
const { query, values } = sqlParser({ blacklistParams: [ 'limit' ] })(getQuery)

@@ -55,0 +54,0 @@ expect(query).toBe(correctQuery)

Sorry, the diff of this file is not supported yet

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