assert with status codes
JavaScript
Clone or download
Latest commit 7b0514b May 7, 2017

README.md

http-assert

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

Assert with status codes. Like ctx.throw() in Koa, but with a guard.

Example

var assert = require('http-assert');
var ok = require('assert');

try {
  assert(username == 'fjodor', 401, 'authentication failed');
} catch (err) {
  ok(err.status == 401);
  ok(err.message == 'authentication failed');
  ok(err.expose);
}

Licence

MIT