Socket
Socket
Sign inDemoInstall

throwback

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

throwback

An asynchronous middleware pattern


Version published
Weekly downloads
127K
increased by0.18%
Maintainers
1
Weekly downloads
 
Created
Source

Throwback

NPM version NPM downloads Build status Test coverage

An asynchronous middleware pattern.

Installation

npm install throwback --save

Usage

Compose asynchronous functions (promise-based)

import { compose, resolve } from 'throwback'

const fn = compose([
  async function (req, res, next) {
    console.log(1)

    try {
      await next()
    } catch (err) {
      console.log('throwback', err)
    }

    console.log(4)
  },
  async function (req, res, next) {
    console.log(2)

    return next()
  }
])

// Or replace the callback here with `resolve`, which returns
// `Promise.resolve()` triggering the bubble back up the middleware stack.
fn({}, {}, function (req, res) {
  console.log(3)

  res.status = 404
})

Inspiration

Built for popsicle and inspired by koa-compose.

License

MIT

Keywords

FAQs

Package last updated on 07 May 2016

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