Socket
Book a DemoInstallSign in
Socket

express-insert-mw

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-insert-mw

Call express middlewares just before calling next or sending response

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Express Insert Middleware

Call express middlewares just before calling next or sending response

Installation

$ npm install express-insert-middleware

Usage

Use this module to manualy call middleware inside your express

For example,

var insertMiddleware = require('express-insert-mw');

/* Init your express app */

/* Create a basic middleware */
function loadProfileInfo(req, res, next) {
    /* Load informations from BDD { */
        req.user = {
            name: nameFromBDD
        };
        next();
    /* } */
}
app.use(loadProfileInfo);

/* Basic profile page */
app.get('/profile',
    function(req, res) {
        res.send('Hello ' + req.user.name);
    }
);

/* Edit profile request */
app.post('/profile',
    function(req, res) {

        /* Set new profile information in BDD { */

            /* Then reload profile informations with the middleware */
            insertMiddleware(req, res, [loadProfileInfo], function(req, res) {
                res.send('Hello ' + req.user.name);
            });

        /* } */

    }
);

You can pass an array of multiple middlewares

License

This project is licensed under the MIT license.

Keywords

express

FAQs

Package last updated on 14 Oct 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.