Gathering detailed insights and metrics for ynn-http-assert
Gathering detailed insights and metrics for ynn-http-assert
Gathering detailed insights and metrics for ynn-http-assert
Gathering detailed insights and metrics for ynn-http-assert
npm install ynn-http-assert
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
14 Commits
1 Watchers
12 Branches
1 Contributors
Updated on Jan 31, 2020
Latest Version
0.0.6
Package Id
ynn-http-assert@0.0.6
Unpacked Size
13.03 kB
Size
4.19 kB
File Count
7
NPM Version
6.13.6
Node Version
13.5.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
3
Like http-assert, but has more features for using in some web frameworks, such as Koa.
1$ npm i --save ynn-http-assert
1const koa = require( 'koa' ); 2const assert = require( 'ynn-http-assert' ); 3 4const app = new Koa(); 5 6app.use( async ( ctx, next ) => { 7 const id = assert( ctx.query.id, 400, 'id is required' ) 8 .is( 'int', 'invalid id' ) 9 .between( [ 100, 1000 ] ) 10 .value(); 11 12 const pn = assert( ctx.query.pn ) 13 .default( 1 ) 14 .is( 'int' ) 15 .gt( 0 ) 16 .value(); 17 18 const email = assert( ctx.query.email, 400, 'email is required' ) 19 .is( 'email' ) 20 .custom( v => v.startWith( 'abc' ) ) 21 .value(); 22 23 const username = await assert( ctx.query.username ) 24 .custom( v => { 25 return Promise.reject(); 26 }, 400, 'username is invalid' ) 27 .value(); 28 29 return next(); 30} );
assert(value, [status], [message], [properties])
default(value)
To set a default value if the value doesn't pass any of the assertions, and then all the assertions rest will be ignored.
1const x = assert( ctx.query.x ) // if the ctx.query.x is not truthy, the value will be set to 100 2 .default( 100 ) 3 .is( 'int' ) // if the value is not an integer, the value will be set to 100 4 .value();
value([v])
To set/get the value of Assertion instance.
1const x = assert( ctx.query.x ) 2 .custom( function( v ) { 3 this.value( 'new-value' ); // to set the value to 'new-value' 4 } ). 5 value(); // to get the value
equal(data, [status], [message], [properties])
notEqual(data, [status], [message], [properties])
strictEqual(data, [status], [message], [properties])
notStrictEqual(data, [status], [message], [properties])
deepEqual(data, [status], [message], [properties])
notDeepEqual(data, [status], [message], [properties])
is(type, [status], [message], [properties])
gt(n, [status], [message], [properties])
gte(n, [status], [message], [properties])
lt(n, [status], [message], [properties])
lte(n, [status], [message], [properties])
between(interval, [status], [message], [properties])
length(interval, [status], [message], [properties])
regex(regex, [status], [message], [properties])
json(fn, [status], [message], [properties])
jsonstr(fn, [status], [message], [properties]) custom(fn, [status], [message], [properties])
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
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
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
32 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
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