0.0.1 • Published 8 years ago

saba v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Sāba

NPM version NPM downloads Build Status

Install

$ npm install --save saba

Usage

const {saba, send} = require('saba')

const app = saba((req, res) => {
  if (req.url === '/404') {
    return sned(res, 'not found', 404)
  }
  send(res, 'hello world')
})

app.listen(3000)

Handle Error

const handleError = fn => {
  return async (req, res) => {
    try {
      await fn(req, res)
    } catch (err) {
      // perform your logic here...
      console.log(err.stack)
    }
  }
}

saba(handleError(async (req, res) => {
  send(res, 'ready')
}))

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT © EGOIST