diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:38:48 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 21:53:09 +0800 |
| commit | 26105034da4fcce7ac883c899d781f016559310d (patch) | |
| tree | c459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/http-assert | |
| parent | 2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff) | |
| download | xmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip | |
switch to vuepress
Diffstat (limited to 'node_modules/http-assert')
| -rw-r--r-- | node_modules/http-assert/HISTORY.md | 65 | ||||
| -rw-r--r-- | node_modules/http-assert/LICENSE | 22 | ||||
| -rw-r--r-- | node_modules/http-assert/README.md | 112 | ||||
| -rw-r--r-- | node_modules/http-assert/index.js | 37 | ||||
| -rw-r--r-- | node_modules/http-assert/package.json | 41 |
5 files changed, 277 insertions, 0 deletions
diff --git a/node_modules/http-assert/HISTORY.md b/node_modules/http-assert/HISTORY.md new file mode 100644 index 00000000..ce503280 --- /dev/null +++ b/node_modules/http-assert/HISTORY.md @@ -0,0 +1,65 @@ +1.4.0 / 2018-09-09 +================== + + * Add `assert.ok()` + * deps: http-errors@~1.7.1 + - Set constructor name when possible + - deps: depd@~1.1.2 + - deps: setprototypeof@1.1.0 + - deps: statuses@'>= 1.5.0 < 2' + +1.3.0 / 2017-05-07 +================== + + * deps: deep-equal@~1.0.1 + - Fix `null == undefined` for non-strict compares + * deps: http-errors@~1.6.1 + - Accept custom 4xx and 5xx status codes in factory + - Deprecate using non-error status codes + - Make `message` property enumerable for `HttpError`s + - Support new code `421 Misdirected Request` + - Use `setprototypeof` module to replace `__proto__` setting + - deps: inherits@2.0.3 + - deps: setprototypeof@1.0.3 + - deps: statuses@'>= 1.3.1 < 2' + - perf: enable strict mode + +1.2.0 / 2016-02-27 +================== + + * deps: http-errors@~1.4.0 + +1.1.1 / 2015-02-13 +================== + + * deps: deep-equal@~1.0.0 + * dpes: http-errors@~1.3.1 + +1.1.0 / 2014-12-10 +================== + + * Add equality methods + - `assert.deepEqual()` + - `assert.equal()` + - `assert.notDeepEqual()` + - `assert.notEqual()` + - `assert.notStrictEqual()` + - `assert.strictEqual()` + +1.0.2 / 2014-09-10 +================== + + * Fix setting `err.expose` on invalid status + * Use `http-errors` module + * perf: remove duplicate status check + +1.0.1 / 2014-01-20 +================== + + * Fix typo causing `err.message` to be `undefined` + +1.0.0 / 2014-01-20 +================== + + * Default status to 500 + * Set `err.expose` to `false` for 5xx codes diff --git a/node_modules/http-assert/LICENSE b/node_modules/http-assert/LICENSE new file mode 100644 index 00000000..3ee2c011 --- /dev/null +++ b/node_modules/http-assert/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2014 + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/http-assert/README.md b/node_modules/http-assert/README.md new file mode 100644 index 00000000..6f75b1d6 --- /dev/null +++ b/node_modules/http-assert/README.md @@ -0,0 +1,112 @@ +# http-assert + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Assert with status codes. Like ctx.throw() in Koa, but with a guard. + +## Install + +This is a [Node.js](https://nodejs.org/en/) module available through the +[npm registry](https://www.npmjs.com/). Installation is done using the +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): + +```bash +$ npm install http-assert +``` + +## Example +```js +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](https://nodejs.org/dist/latest/docs/api/assert.html). + +Each function will throw an instance of `HttpError` from +[the `http-errors` module](https://www.npmjs.com/package/http-errors) +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](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/http-assert.svg +[npm-url]: https://npmjs.org/package/http-assert +[node-version-image]: https://img.shields.io/node/v/http-assert.svg +[node-version-url]: https://nodejs.org/en/download/ +[travis-image]: https://img.shields.io/travis/jshttp/http-assert/master.svg +[travis-url]: https://travis-ci.org/jshttp/http-assert +[coveralls-image]: https://img.shields.io/coveralls/jshttp/http-assert/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/http-assert +[downloads-image]: https://img.shields.io/npm/dm/http-assert.svg +[downloads-url]: https://npmjs.org/package/http-assert diff --git a/node_modules/http-assert/index.js b/node_modules/http-assert/index.js new file mode 100644 index 00000000..0dbf3066 --- /dev/null +++ b/node_modules/http-assert/index.js @@ -0,0 +1,37 @@ +var createError = require('http-errors') +var eql = require('deep-equal') + +module.exports = assert + +function assert (value, status, msg, opts) { + if (value) return + throw createError(status, msg, opts) +} + +assert.equal = function (a, b, status, msg, opts) { + assert(a == b, status, msg, opts) // eslint-disable-line eqeqeq +} + +assert.notEqual = function (a, b, status, msg, opts) { + assert(a != b, status, msg, opts) // eslint-disable-line eqeqeq +} + +assert.ok = function (value, status, msg, opts) { + assert(value, status, msg, opts) +} + +assert.strictEqual = function (a, b, status, msg, opts) { + assert(a === b, status, msg, opts) +} + +assert.notStrictEqual = function (a, b, status, msg, opts) { + assert(a !== b, status, msg, opts) +} + +assert.deepEqual = function (a, b, status, msg, opts) { + assert(eql(a, b), status, msg, opts) +} + +assert.notDeepEqual = function (a, b, status, msg, opts) { + assert(!eql(a, b), status, msg, opts) +} diff --git a/node_modules/http-assert/package.json b/node_modules/http-assert/package.json new file mode 100644 index 00000000..7c737f14 --- /dev/null +++ b/node_modules/http-assert/package.json @@ -0,0 +1,41 @@ +{ + "name": "http-assert", + "description": "assert with status codes", + "version": "1.4.0", + "license": "MIT", + "keywords": [ + "assert", + "http" + ], + "repository": "jshttp/http-assert", + "dependencies": { + "deep-equal": "~1.0.1", + "http-errors": "~1.7.1" + }, + "devDependencies": { + "eslint": "5.5.0", + "eslint-config-standard": "12.0.0", + "eslint-plugin-import": "2.14.0", + "eslint-plugin-markdown": "1.0.0-beta.6", + "eslint-plugin-node": "7.0.1", + "eslint-plugin-promise": "4.0.0", + "eslint-plugin-standard": "4.0.0", + "istanbul": "0.4.5", + "mocha": "2.5.3" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.8" + }, + "scripts": { + "lint": "eslint --plugin markdown --ext js,md .", + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + } +} |
