express-enum-param

0.1.0 • Public • Published

express-enum-param

Middleware for ensuring that a request parameter can only assume certain values

Installation

$ npm install --save express-enum-param

Requires body-parser.

Usage

import enumParam from 'express-enum-param';
 
let allowedAnimals = ['crocodile', 'heron', 'turtle'];
 
router.get('/', 
    enumParam('animal', allowedAnimals),
    (req, res) => {
    res.status(200).send();
});

The above code will return a 400 HTTP status code and a message informing the client that this parameter can only have values from a certain list if animal is anything else than crocodile, heron, or turtle.

About

License

Copyright © 2018, nukeop. Released under the Affero GPL 3.0 License.

Readme

Keywords

Package Sidebar

Install

npm i express-enum-param

Weekly Downloads

4

Version

0.1.0

License

AGPL-3.0

Unpacked Size

36.4 kB

Total Files

4

Last publish

Collaborators

  • nukeop