Skip to content

Latest commit

 

History

History
103 lines (62 loc) · 5.53 KB

File metadata and controls

103 lines (62 loc) · 5.53 KB

express-universal-query-validator

src/index.js:6-6

Express middleware to provide consistently parseable query parameters to universal applications

defaultRedirect

src/index.js:29-40

Default callback behavior for the middleware Can be replaced by passing a function argument in the first position to queryValidator. It will receive the same arguments.

Parameters

Returns undefined

queryValidator

src/index.js:54-92

Create a middleware to validate queries are parseable by both the browser and node. This should be mounted early.

Parameters

  • cb [Function?](default defaultRedirect) called to handle invalid params. passed req, res, next and a context object containing useful data. The default behavior is to console.error and res.redirect
  • options [Object?](default {})
    • options.delimiter string? query string delimiter

Returns Function middleware - the middleware function to use

middleware

src/index.js:63-91

Parameters

Returns undefined

express-universal-query-validator/util

src/util/index.js:6-6

Utility functions needed for this module

isUnparseableQuery

src/util/index.js:15-17

Checks if a key=value param can not be parsed by global decodeURIComponent

Parameters

  • query [string](default 'key=value')

Returns boolean did parsing throw?

validateQueryParams

src/util/index.js:24-26

Are all queries parseable?

Parameters

  • queries [Array](default [])

Returns boolean

dropInvalidQueryParams

src/util/index.js:33-35

Returns input minus unparseable queries

Parameters

  • queries [Array](default [])

Returns Array