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

express-args

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-args

Predictable state requests. Autoparams function.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

express-args

Predictable state in request parameters

  • Redux
  • State subscription
  • Auto parameters
  • Middleware for ExpressJS
  • Request logger

Usage

Request example:

http://localhost:3000/?id=1&name=julian&lastname=david&fk=1

http://localhost:3000/?token=3s5iuds42xl8

The capture of arguments is dynamic, everything is based on the names of the parameters of each function:

// conf_express_args.js

var ex_args = require('express-args')

var config = [{
  type: ex_args.constants.AUTO_PARAMS,
  exec: function (req, res, next, id, name, lastname, fk) {
    console.log("Autoparams 1:", id, name, lastname, fk);
    //=> Autoparams 1: 1 julian david 1
    res.send("Middleware")
  }
}, {
  type: ex_args.constants.AUTO_PARAMS,
  exec: function (req, res, next, token) {
    console.log("Autoparams 2:", token);
    //=> Autoparams 2: 3s5iuds42xl8
    res.send('Token:' + token)
  }
}]

ex_args.conf(config);

module.exports = ex_args;

Do you want to subscribe to middleware state?

// Observable

ex_args.store.subscribe(() => {
  console.log("Actual state:", ex_args.store.getState())
})

Using with ExpressJS

// app.js

/* ... */
var app = express();
var express_args = require('./conf_express_args');

app.use(express_args.app);

/* ... */

A closer look at the middleware and server.

Project under development.

License MIT @juliandavidmr

Keywords

FAQs

Package last updated on 11 May 2017

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