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

chaindler

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chaindler

A simple request handler (controller/middleware) chainer

  • 0.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-76.92%
Maintainers
1
Weekly downloads
 
Created
Source

chaindler NPM Build Coverage License

A simple request handler (controller/middleware) chainer.

Installation

$ npm i chaindler

Usage

1. Import chaindler

const { Chain } = require('chaindler');

2. Write your middlewares

function mw1 (req, res, next) {
  console.log('1');
  next();
}

function mw2 (req, res, next) {
  console.log('2');
  next();
}

function mw3 (req, res, next) {
  console.log('3');
  next();
}

3. Write your controller

function controller (req, res, next) {
  res.send('hello');
}

4. Chain them up!

import express = require('express');
const app = express();
app.use('/hello', new Chain(mw1, mw2, mw3).handle(controller));

NOTE: Example was with the assumption you are using express.js

This module was developed with Node.js servers that uses swagger-node, express-openapi, and other kinds of modules that limits your ability to chain middlewares in mind.

These kinds of modules would require you to have your controllers in an object, and to use chaindler in that scenario would be something like this:

const controllers = {
  operation1: new Chain(mw1, mw2, mw3).handle(controller),
  operation2: new Chain(mw1, mw2, mw3).handle(controller),
}

Authors

  • Zishran Garces

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

FAQs

Package last updated on 26 Dec 2020

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