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

express-functional-control

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-functional-control

Some tools to make it easier to tie express routes to model functions

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

express-functional-control

Some tools to make it easier to tie express routes to model functions (inside any controller function). Just getting rid of repetitive stuff like this:

# users.coffee (a controller)
exports.getUser = (req, res) -> 
  User.findOne {userId: req.params.userId}, (err, user) ->
    if err? then return res.send 500, {message: err.message}
    if not user? then return res.send 404
    res.send user

Example of Use:

# users.coffee (a controller)
{send, ok} = require 'express-functional-control'

# sends 200 {object}, 500 {error}, or 404
exports.getUser = (req, res) -> 
  User.findOne {userId: req.params.userId}, send(res)

# sends 200 OK or 500 {error}
exports.saveUser = (req, res) ->
  user = new User req.body
  user.save ok(res)

FAQs

Package last updated on 04 Oct 2012

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