Installations
npm install http-assert
Developer Guide
Typescript
No
Module System
N/A
Min. Node Version
>= 0.8
Node Version
16.1.0
NPM Version
7.11.2
Score
99
Supply Chain
97.7
Quality
79
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
jshttp
Download Statistics
Total Downloads
334,618,592
Last Day
544,034
Last Week
2,439,430
Last Month
10,302,166
Last Year
96,701,591
GitHub Statistics
152 Stars
143 Commits
15 Forks
13 Watching
1 Branches
30 Contributors
Bundle Size
7.95 kB
Minified
3.02 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.5.0
Package Id
http-assert@1.5.0
Size
3.06 kB
NPM Version
7.11.2
Node Version
16.1.0
Publised On
25 Aug 2021
Total Downloads
Cumulative downloads
Total Downloads
334,618,592
Last day
4.2%
544,034
Compared to previous day
Last week
-10.3%
2,439,430
Compared to previous week
Last month
9.6%
10,302,166
Compared to previous month
Last year
37.8%
96,701,591
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
http-assert
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:
1$ npm install http-assert
Example
1var assert = require('http-assert') 2var ok = require('assert') 3 4var username = 'foobar' // username from request 5 6try { 7 assert(username === 'fjodor', 401, 'authentication failed') 8} catch (err) { 9 ok(err.status === 401) 10 ok(err.message === 'authentication failed') 11 ok(err.expose) 12}
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.fail([status], [message], [properties])
Always throws an HttpError
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
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/jshttp/.github/SECURITY.md:1
- Warn: no linked content found
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/jshttp/.github/SECURITY.md:1
- Info: Found text in security policy: github.com/jshttp/.github/SECURITY.md:1
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:218: update your workflow using https://app.stepsecurity.io/secureworkflow/jshttp/http-assert/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:133: update your workflow using https://app.stepsecurity.io/secureworkflow/jshttp/http-assert/ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:206: update your workflow using https://app.stepsecurity.io/secureworkflow/jshttp/http-assert/ci.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:166
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:182
- Info: 3 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 3 third-party GitHubAction dependencies pinned
- Info: 0 out of 2 npmCommand dependencies pinned
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: topLevel permissions set to 'read-all': .github/workflows/scorecard.yml:18
- Info: no jobLevel write permissions found
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Score
3.8
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More