http-assert

1.3.0 • Public • Published

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

Keywords

install

npm i http-assert

Downloadsweekly downloads

166,659

version

1.3.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
Report a vulnerability