Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including express-params-handler with all npm packages installed. Try it out:

var expressParamsHandler = require("express-params-handler")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

express-params-handler v0.2.0

Express.js params handler

express-params-handler

Express.js v4+ params handler

This lib is replacement of express-params which is made for Express 2.5. Express v4+ deprecated number of features which are in use of that original library. This lib offers similar functionality but doesn't use deprecated methods of new Express.

Installation

npm i express-params-handler

Usage

var expressParams = require('express-params-handler')

var app = express()

app.param('id', expressParams(Number))
app.param('date', expressParams(/^\d{4}-\d{2}-\d{2}$/))

app.get('/by-id/:id', function(req, res, next) {
  // req.params.id will be a number
})

app.get('/by-date/:date', function(req, res, next) {
  // req.params.date will be a string with YYYY-MM-DD format
})

Licence

MIT

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free