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

caco-express

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

caco-express

Express middleware wrapper using caco generator function

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

caco-express

Express middleware wrapper for caco generator function.

Build Status

npm install caco-express

This is a caco version of co-express, which supports 'yielding' callback functions using next(err, val).

Calling next() without argument, passes control to the next middleware stack.

var express = require('express')
var wrap = require('caco-express')
var fs = require('fs')

var app = express()

app.get('/foo', wrap(function * (req, res, next) {
  // yield callback function using caco next(err, val)
  req.data = yield fs.readFile('./data.json', 'utf8', next)
  yield setTimeout(next, 10)

  next() // calling next() passes to next middleware
}, function * (req, res) {
  res.send(data)
}))

// 4 arguments for error handling middleware
app.use(wrap(function * (err, req, res, next) {
  res.status(500).send({ 
    success: false, 
    message: err.message 
  })
}))

License

MIT

FAQs

Package last updated on 11 Jun 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