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

beware

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beware

Lightweight async/await middleware library (formerly middlewerewolf)

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by500%
Maintainers
1
Weekly downloads
 
Created
Source

Beware

Lightweight async/await middleware library (formerly middlewerewolf)

Installation

yarn add beware

Usage

import Beware from "beware";
let app = new Beware();

// This middleware will execute without issue
app.use(async (ctx, next) => {
  ctx.foo = true;
  await next();
});

// This middleware will execute, but does not call next()
app.use(async ctx => {
  ctx.bar = true;
});

// This middleware will not execute, as the previous middleware
// did not call next()
app.use(async ctx => {
  ctx.baz = true;
});

// Register multiple middleware with a single command
app.all([
  async ctx => {
    ctx.foo = true;
    await next();
  },
  async ctx => {
    ctx.bar = true;
    await next();
  }
]);

// Compose a new middleware execution chain
let fn = app.compose();

// Execute the chain
fn({
  initial_context: true
}).then(ctx => {
  console.log("All done here!");
}).catch(err => {
  console.log("Handle errors like a boss.");
});

Build beware

git clone git@github.com:aewing/beware.git
cd beware/
make lint
make flow
make test
make build

Contributing

Pull requests are welcome, but I intend to keep this package as lightweight and future compliant as possible.

Credits

Much love to koa-compose, which inspired this package.

Keywords

FAQs

Package last updated on 02 Sep 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