Template Upload
This commit is contained in:
21
node_modules/popsicle-status/LICENSE
generated
vendored
Normal file
21
node_modules/popsicle-status/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
|
||||
|
||||
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.
|
51
node_modules/popsicle-status/README.md
generated
vendored
Normal file
51
node_modules/popsicle-status/README.md
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
# Popsicle Status
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![NPM downloads][downloads-image]][downloads-url]
|
||||
[![Build status][travis-image]][travis-url]
|
||||
[![Test coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Reject responses on HTTP failure status codes (404, 500, etc).
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install popsicle-status --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var request = require('popsicle')
|
||||
var status = require('popsicle-status')
|
||||
|
||||
request('/users.json')
|
||||
.use(status())
|
||||
.catch(function (error) {
|
||||
console.log(error.type) //=> "EINVALIDSTATUS"
|
||||
console.log(error.message) //=> "Invalid HTTP status, 404, should be between 200 and 399"
|
||||
console.log(error.status) //=> 404
|
||||
console.log(error.popsicle) //=> Popsicle#Request
|
||||
})
|
||||
```
|
||||
|
||||
* **status()** Use default status codes (min: `200`, max: `399`)
|
||||
* **status(number)** Set the only valid HTTP status code
|
||||
* **status(number, number)** Set both the minimum and maximum HTTP status codes
|
||||
|
||||
## TypeScript
|
||||
|
||||
Includes a [type definition](popsicle-status.d.ts) for TypeScript.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/popsicle-status.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/popsicle-status
|
||||
[downloads-image]: https://img.shields.io/npm/dm/popsicle-status.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/popsicle-status
|
||||
[travis-image]: https://img.shields.io/travis/blakeembrey/popsicle-status.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/blakeembrey/popsicle-status
|
||||
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/popsicle-status.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/blakeembrey/popsicle-status?branch=master
|
101
node_modules/popsicle-status/package.json
generated
vendored
Normal file
101
node_modules/popsicle-status/package.json
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"popsicle-status@^1.0.1",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\typings-core"
|
||||
]
|
||||
],
|
||||
"_from": "popsicle-status@>=1.0.1-0 <2.0.0-0",
|
||||
"_id": "popsicle-status@1.0.2",
|
||||
"_inCache": true,
|
||||
"_location": "/popsicle-status",
|
||||
"_nodeVersion": "5.7.1",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/popsicle-status-1.0.2.tgz_1459470515645_0.7759254511911422"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "hello@blakeembrey.com",
|
||||
"name": "blakeembrey"
|
||||
},
|
||||
"_npmVersion": "3.6.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "popsicle-status",
|
||||
"raw": "popsicle-status@^1.0.1",
|
||||
"rawSpec": "^1.0.1",
|
||||
"scope": null,
|
||||
"spec": ">=1.0.1-0 <2.0.0-0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/typings-core"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/popsicle-status/-/popsicle-status-1.0.2.tgz",
|
||||
"_shasum": "a02416727580724412e09d1303f067cea3ca0e13",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "popsicle-status@^1.0.1",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\typings-core",
|
||||
"author": {
|
||||
"email": "hello@blakeembrey.com",
|
||||
"name": "Blake Embrey",
|
||||
"url": "http://blakeembrey.me"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/blakeembrey/popsicle-status/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Reject Popsicle responses on HTTP failure status codes",
|
||||
"devDependencies": {
|
||||
"bluebird": "^3.0.5",
|
||||
"chai": "^3.3.0",
|
||||
"istanbul": "^0.4.1",
|
||||
"mocha": "^2.0.1",
|
||||
"nock": "^5.2.1",
|
||||
"popsicle": "^3.0.0",
|
||||
"pre-commit": "^1.0.6",
|
||||
"standard": "^5.3.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "a02416727580724412e09d1303f067cea3ca0e13",
|
||||
"tarball": "https://registry.npmjs.org/popsicle-status/-/popsicle-status-1.0.2.tgz"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"popsicle-status.d.ts",
|
||||
"popsicle-status.js"
|
||||
],
|
||||
"gitHead": "bc90736c8865ebb8b27d5484818e82b2c038e803",
|
||||
"homepage": "https://github.com/blakeembrey/popsicle-status",
|
||||
"installable": true,
|
||||
"keywords": [
|
||||
"http",
|
||||
"plugin",
|
||||
"popsicle",
|
||||
"response",
|
||||
"status"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "popsicle-status.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "blakeembrey",
|
||||
"email": "hello@blakeembrey.com"
|
||||
}
|
||||
],
|
||||
"name": "popsicle-status",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/blakeembrey/popsicle-status.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test": "npm run lint && npm run test-cov",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- -R spec --bail",
|
||||
"test-spec": "mocha -R spec --bail"
|
||||
},
|
||||
"typings": "popsicle-status.d.ts",
|
||||
"version": "1.0.2"
|
||||
}
|
5
node_modules/popsicle-status/popsicle-status.d.ts
generated
vendored
Normal file
5
node_modules/popsicle-status/popsicle-status.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
declare function popsicleStatus (): (response: any) => any;
|
||||
declare function popsicleStatus (statusCode: number): (response: any) => any;
|
||||
declare function popsicleStatus (lowerStatusCode: number, upperStatusCode: number): (response: any) => any;
|
||||
|
||||
export = popsicleStatus;
|
36
node_modules/popsicle-status/popsicle-status.js
generated
vendored
Normal file
36
node_modules/popsicle-status/popsicle-status.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
module.exports = popsicleStatus
|
||||
|
||||
function popsicleStatus () {
|
||||
var lower = 200
|
||||
var upper = 399
|
||||
|
||||
if (arguments.length === 1) {
|
||||
lower = arguments[0]
|
||||
upper = arguments[0]
|
||||
}
|
||||
|
||||
if (arguments.length === 2) {
|
||||
lower = arguments[0]
|
||||
upper = arguments[1]
|
||||
}
|
||||
|
||||
return function (req) {
|
||||
req.after(function (res) {
|
||||
if (res.status >= lower && res.status <= upper) {
|
||||
return res
|
||||
}
|
||||
|
||||
var message
|
||||
|
||||
if (lower === upper) {
|
||||
message = 'equal ' + upper
|
||||
} else {
|
||||
message = 'be between ' + lower + ' and ' + upper
|
||||
}
|
||||
|
||||
var error = res.error(req.url + ' responded with ' + res.status + ', expected it to ' + message, 'EINVALIDSTATUS')
|
||||
error.status = res.status
|
||||
throw error
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user