http-assert

WebJar for http-assert

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

http-assert
Last Version

Last Version

1.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

http-assert
WebJar for http-assert
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/jshttp/http-assert

Download http-assert

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/http-assert/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>http-assert</artifactId>
    <version>1.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/http-assert/
implementation 'org.webjars.npm:http-assert:1.3.0'
// https://jarcasting.com/artifacts/org.webjars.npm/http-assert/
implementation ("org.webjars.npm:http-assert:1.3.0")
'org.webjars.npm:http-assert:jar:1.3.0'
<dependency org="org.webjars.npm" name="http-assert" rev="1.3.0">
  <artifact name="http-assert" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='http-assert', version='1.3.0')
)
libraryDependencies += "org.webjars.npm" % "http-assert" % "1.3.0"
[org.webjars.npm/http-assert "1.3.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : deep-equal jar [1.0.1,1.1)
org.webjars.npm : http-errors jar [1.6.1,1.7)

Project Modules

There are no modules declared in this project.

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.

Install

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install http-assert

Example

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

var username = 'foobar' // username from request

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

API

The API of this module is intended to be similar to the Node.js assert module.

Each function will throw an instance of HttpError from the http-errors module when the assertion fails.

assert(value, [status], [message], [properties])

Tests if value is truthy. If value is not truthy, an HttpError is thrown that is constructed with the given status, message, and properties.

assert.deepEqual(a, b, [status], [message], [properties])

Tests for deep equality between a and b. Primitive values are compared with the Abstract Equality Comparison (==). If a and b are not equal, an HttpError is thrown that is constructed with the given status, message, and properties.

assert.equal(a, b, [status], [message], [properties])

Tests shallow, coercive equality between a and b using the Abstract Equality Comparison (==). If a and b are not equal, an HttpError is thrown that is constructed with the given status, message, and properties.

assert.notDeepEqual(a, b, [status], [message], [properties])

Tests for deep equality between a and b. Primitive values are compared with the Abstract Equality Comparison (==). If a and b are equal, an HttpError is thrown that is constructed with the given status, message, and properties.

assert.notEqual(a, b, [status], [message], [properties])

Tests shallow, coercive equality between a and b using the Abstract Equality Comparison (==). If a and b are equal, an HttpError is thrown that is constructed with the given status, message, and properties.

assert.notStrictEqual(a, b, [status], [message], [properties])

Tests strict equality between a and b as determined by the SameValue Comparison (===). If a and b are equal, an HttpError is thrown that is constructed with the given status, message, and properties.

assert.ok(value, [status], [message], [properties])

Tests if value is truthy. If value is not truthy, an HttpError is thrown that is constructed with the given status, message, and properties.

assert.strictEqual(a, b, [status], [message], [properties])

Tests strict equality between a and b as determined by the SameValue Comparison (===). If a and b are not equal, an HttpError is thrown that is constructed with the given status, message, and properties.

Licence

MIT

org.webjars.npm
Low-Level JavaScript HTTP-related Modules

Versions

Version
1.3.0