middleware-exec

1.0.0 • Public • Published

middleware-exec

Simple way to create middleware that should not modify the response.

Takes care of errors.

Useful for tasks like updating the database.

Example

router.post '/user/:id',
    exec (req, next) -> dao.user.update req.params.id, req.body, next

Without exec

router.post '/user/:id',
    dao.user.update req.params.id, req.body, (err) ->
        if err?
            res.writeHead 500
            res.end 'Internal Server Error'
        else
            next()

Credits

bind was developed with snd during a project. The initial idea is from snd. I refactored the library and provided unit tests.

Readme

Keywords

none

Package Sidebar

Install

npm i middleware-exec

Weekly Downloads

2

Version

1.0.0

License

none

Last publish

Collaborators

  • mren