docs:更新文档

This commit is contained in:
张益铭
2021-03-01 15:06:11 +08:00
parent 1542135ab0
commit 9064b372e8
5835 changed files with 904126 additions and 161722 deletions

23
node_modules/path-match/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
(The MIT License)
Copyright (c) 2014 segmentio <team@segment.io>
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.

55
node_modules/path-match/README.md generated vendored Normal file
View File

@@ -0,0 +1,55 @@
# path match
[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
Thin wrapper around [path-to-regexp](https://github.com/component/path-to-regexp) to make extracting the param names easier.
```js
var route = require('path-match')({
// path-to-regexp options
sensitive: false,
strict: false,
end: false,
});
// create a match function from a route
var match = route('/post/:id');
// match a route
var parse = require('url').parse;
require('http').createServer(function (req, res) {
var params = match(parse(req.url).pathname);
// no match
if (params === false) {
res.statusCode = 404;
res.end();
return;
}
// the matched id
var id = params.id;
// do stuff with the ID
})
```
[npm-image]: https://img.shields.io/npm/v/path-match.svg?style=flat-square
[npm-url]: https://npmjs.org/package/path-match
[github-tag]: http://img.shields.io/github/tag/pillarjs/path-match.svg?style=flat-square
[github-url]: https://github.com/pillarjs/path-match/tags
[travis-image]: https://img.shields.io/travis/pillarjs/path-match.svg?style=flat-square
[travis-url]: https://travis-ci.org/pillarjs/path-match
[coveralls-image]: https://img.shields.io/coveralls/pillarjs/path-match.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/pillarjs/path-match?branch=master
[david-image]: http://img.shields.io/david/pillarjs/path-match.svg?style=flat-square
[david-url]: https://david-dm.org/pillarjs/path-match
[license-image]: http://img.shields.io/npm/l/path-match.svg?style=flat-square
[license-url]: LICENSE.md
[downloads-image]: http://img.shields.io/npm/dm/path-match.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/path-match

38
node_modules/path-match/index.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
var pathToRegexp = require('path-to-regexp');
var createError = require('http-errors');
module.exports = function (options) {
options = options || {};
return function (path) {
var keys = [];
var re = pathToRegexp(path, keys, options);
return function (pathname, params) {
var m = re.exec(pathname);
if (!m) return false;
params = params || {};
var key, param;
for (var i = 0; i < keys.length; i++) {
key = keys[i];
param = m[i + 1];
if (!param) continue;
params[key.name] = decodeParam(param);
if (key.repeat) params[key.name] = params[key.name].split(key.delimiter)
}
return params;
}
}
}
function decodeParam(param) {
try {
return decodeURIComponent(param);
} catch (_) {
throw createError(400, 'failed to decode param "' + param + '"');
}
}

View File

@@ -0,0 +1,85 @@
2016-01-28 / 1.4.0
==================
* Add `HttpError` export, for `err instanceof createError.HttpError`
* deps: inherits@2.0.1
* deps: statuses@'>= 1.2.1 < 2'
- Fix message for status 451
- Remove incorrect nginx status code
2015-02-02 / 1.3.1
==================
* Fix regression where status can be overwritten in `createError` `props`
2015-02-01 / 1.3.0
==================
* Construct errors using defined constructors from `createError`
* Fix error names that are not identifiers
- `createError["I'mateapot"]` is now `createError.ImATeapot`
* Set a meaningful `name` property on constructed errors
2014-12-09 / 1.2.8
==================
* Fix stack trace from exported function
* Remove `arguments.callee` usage
2014-10-14 / 1.2.7
==================
* Remove duplicate line
2014-10-02 / 1.2.6
==================
* Fix `expose` to be `true` for `ClientError` constructor
2014-09-28 / 1.2.5
==================
* deps: statuses@1
2014-09-21 / 1.2.4
==================
* Fix dependency version to work with old `npm`s
2014-09-21 / 1.2.3
==================
* deps: statuses@~1.1.0
2014-09-21 / 1.2.2
==================
* Fix publish error
2014-09-21 / 1.2.1
==================
* Support Node.js 0.6
* Use `inherits` instead of `util`
2014-09-09 / 1.2.0
==================
* Fix the way inheriting functions
* Support `expose` being provided in properties argument
2014-09-08 / 1.1.0
==================
* Default status to 500
* Support provided `error` to extend
2014-09-08 / 1.0.1
==================
* Fix accepting string message
2014-09-08 / 1.0.0
==================
* Initial release

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014 Jonathan Ong me@jongleberry.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.

View File

@@ -0,0 +1,66 @@
# http-errors
[![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]
Create HTTP errors for Express, Koa, Connect, etc. with ease.
## Example
```js
var createError = require('http-errors');
app.use(function (req, res, next) {
if (!req.user) return next(createError(401, 'Please login to view this page.'));
next();
})
```
## API
This is the current API, currently extracted from Koa and subject to change.
All errors inherit from JavaScript `Error` and the exported `createError.HttpError`.
### Error Properties
- `expose` - can be used to signal if `message` should be sent to the client, defaulting to `false` when `status` >= 500
- `message`
- `status` and `statusCode` - the status code of the error, defaulting to `500`
### createError([status], [message], [properties])
```js
var err = createError(404, 'This video does not exist!');
```
- `status: 500` - the status code as a number
- `message` - the message of the error, defaulting to node's text for that status code.
- `properties` - custom properties to attach to the object
### new createError\[code || name\](\[msg]\))
```js
var err = new createError.NotFound();
```
- `code` - the status code as a number
- `name` - the name of the error as a "bumpy case", i.e. `NotFound` or `InternalServerError`.
## License
[MIT](LICENSE)
[npm-image]: https://img.shields.io/npm/v/http-errors.svg?style=flat
[npm-url]: https://npmjs.org/package/http-errors
[node-version-image]: https://img.shields.io/node/v/http-errors.svg?style=flat
[node-version-url]: https://nodejs.org/en/download/
[travis-image]: https://img.shields.io/travis/jshttp/http-errors.svg?style=flat
[travis-url]: https://travis-ci.org/jshttp/http-errors
[coveralls-image]: https://img.shields.io/coveralls/jshttp/http-errors.svg?style=flat
[coveralls-url]: https://coveralls.io/r/jshttp/http-errors
[downloads-image]: https://img.shields.io/npm/dm/http-errors.svg?style=flat
[downloads-url]: https://npmjs.org/package/http-errors

View File

@@ -0,0 +1,126 @@
var statuses = require('statuses');
var inherits = require('inherits');
function toIdentifier(str) {
return str.split(' ').map(function (token) {
return token.slice(0, 1).toUpperCase() + token.slice(1)
}).join('').replace(/[^ _0-9a-z]/gi, '')
}
exports = module.exports = function httpError() {
// so much arity going on ~_~
var err;
var msg;
var status = 500;
var props = {};
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (arg instanceof Error) {
err = arg;
status = err.status || err.statusCode || status;
continue;
}
switch (typeof arg) {
case 'string':
msg = arg;
break;
case 'number':
status = arg;
break;
case 'object':
props = arg;
break;
}
}
if (typeof status !== 'number' || !statuses[status]) {
status = 500
}
// constructor
var HttpError = exports[status]
if (!err) {
// create error
err = HttpError
? new HttpError(msg)
: new Error(msg || statuses[status])
Error.captureStackTrace(err, httpError)
}
if (!HttpError || !(err instanceof HttpError)) {
// add properties to generic error
err.expose = status < 500
err.status = err.statusCode = status
}
for (var key in props) {
if (key !== 'status' && key !== 'statusCode') {
err[key] = props[key]
}
}
return err;
};
var HttpError = exports.HttpError = function HttpError() {
throw new TypeError('cannot construct abstract class');
};
inherits(HttpError, Error);
// create generic error objects
var codes = statuses.codes.filter(function (num) {
return num >= 400;
});
codes.forEach(function (code) {
var name = toIdentifier(statuses[code])
var className = name.match(/Error$/) ? name : name + 'Error'
if (code >= 500) {
var ServerError = function ServerError(msg) {
var self = new Error(msg != null ? msg : statuses[code])
Error.captureStackTrace(self, ServerError)
self.__proto__ = ServerError.prototype
Object.defineProperty(self, 'name', {
enumerable: false,
configurable: true,
value: className,
writable: true
})
return self
}
inherits(ServerError, HttpError);
ServerError.prototype.status =
ServerError.prototype.statusCode = code;
ServerError.prototype.expose = false;
exports[code] =
exports[name] = ServerError
return;
}
var ClientError = function ClientError(msg) {
var self = new Error(msg != null ? msg : statuses[code])
Error.captureStackTrace(self, ClientError)
self.__proto__ = ClientError.prototype
Object.defineProperty(self, 'name', {
enumerable: false,
configurable: true,
value: className,
writable: true
})
return self
}
inherits(ClientError, HttpError);
ClientError.prototype.status =
ClientError.prototype.statusCode = code;
ClientError.prototype.expose = true;
exports[code] =
exports[name] = ClientError
return;
});
// backwards-compatibility
exports["I'mateapot"] = exports.ImATeapot

View File

@@ -0,0 +1,84 @@
{
"_args": [
[
"http-errors@1.4.0",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "http-errors@1.4.0",
"_id": "http-errors@1.4.0",
"_inBundle": false,
"_integrity": "sha1-bAJC3qaz33r9oVPHEImzHG6Cqr8=",
"_location": "/path-match/http-errors",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "http-errors@1.4.0",
"name": "http-errors",
"escapedName": "http-errors",
"rawSpec": "1.4.0",
"saveSpec": null,
"fetchSpec": "1.4.0"
},
"_requiredBy": [
"/path-match"
],
"_resolved": "http://192.168.250.101:4873/http-errors/-/http-errors-1.4.0.tgz",
"_spec": "1.4.0",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"bugs": {
"url": "https://github.com/jshttp/http-errors/issues"
},
"contributors": [
{
"name": "Alan Plum",
"email": "me@pluma.io"
},
{
"name": "Douglas Christopher Wilson",
"email": "doug@somethingdoug.com"
}
],
"dependencies": {
"inherits": "2.0.1",
"statuses": ">= 1.2.1 < 2"
},
"description": "Create HTTP error objects",
"devDependencies": {
"istanbul": "0.4.2",
"mocha": "1.21.5"
},
"engines": {
"node": ">= 0.6"
},
"files": [
"index.js",
"HISTORY.md",
"LICENSE",
"README.md"
],
"homepage": "https://github.com/jshttp/http-errors#readme",
"keywords": [
"http",
"error"
],
"license": "MIT",
"name": "http-errors",
"repository": {
"type": "git",
"url": "git+https://github.com/jshttp/http-errors.git"
},
"scripts": {
"test": "mocha --reporter spec --bail",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
},
"version": "1.4.0"
}

16
node_modules/path-match/node_modules/inherits/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,16 @@
The ISC License
Copyright (c) Isaac Z. Schlueter
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

View File

@@ -0,0 +1,42 @@
Browser-friendly inheritance fully compatible with standard node.js
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
This package exports standard `inherits` from node.js `util` module in
node environment, but also provides alternative browser-friendly
implementation through [browser
field](https://gist.github.com/shtylman/4339901). Alternative
implementation is a literal copy of standard one located in standalone
module to avoid requiring of `util`. It also has a shim for old
browsers with no `Object.create` support.
While keeping you sure you are using standard `inherits`
implementation in node.js environment, it allows bundlers such as
[browserify](https://github.com/substack/node-browserify) to not
include full `util` package to your client code if all you need is
just `inherits` function. It worth, because browser shim for `util`
package is large and `inherits` is often the single function you need
from it.
It's recommended to use this package instead of
`require('util').inherits` for any code that has chances to be used
not only in node.js but in browser too.
## usage
```js
var inherits = require('inherits');
// then use exactly as the standard one
```
## note on version ~1.0
Version ~1.0 had completely different motivation and is not compatible
neither with 2.0 nor with standard node.js `inherits`.
If you are using version ~1.0 and planning to switch to ~2.0, be
careful:
* new version uses `super_` instead of `super` for referencing
superclass
* new version overwrites current prototype while old one preserves any
existing fields on it

View File

@@ -0,0 +1 @@
module.exports = require('util').inherits

View File

@@ -0,0 +1,23 @@
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}

View File

@@ -0,0 +1,58 @@
{
"_args": [
[
"inherits@2.0.1",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "inherits@2.0.1",
"_id": "inherits@2.0.1",
"_inBundle": false,
"_integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=",
"_location": "/path-match/inherits",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "inherits@2.0.1",
"name": "inherits",
"escapedName": "inherits",
"rawSpec": "2.0.1",
"saveSpec": null,
"fetchSpec": "2.0.1"
},
"_requiredBy": [
"/path-match/http-errors"
],
"_resolved": "http://192.168.250.101:4873/inherits/-/inherits-2.0.1.tgz",
"_spec": "2.0.1",
"_where": "J:\\Github\\CURD-TS",
"browser": "./inherits_browser.js",
"bugs": {
"url": "https://github.com/isaacs/inherits/issues"
},
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
"homepage": "https://github.com/isaacs/inherits#readme",
"keywords": [
"inheritance",
"class",
"klass",
"oop",
"object-oriented",
"inherits",
"browser",
"browserify"
],
"license": "ISC",
"main": "./inherits.js",
"name": "inherits",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/inherits.git"
},
"scripts": {
"test": "node test"
},
"version": "2.0.1"
}

25
node_modules/path-match/node_modules/inherits/test.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
var inherits = require('./inherits.js')
var assert = require('assert')
function test(c) {
assert(c.constructor === Child)
assert(c.constructor.super_ === Parent)
assert(Object.getPrototypeOf(c) === Child.prototype)
assert(Object.getPrototypeOf(Object.getPrototypeOf(c)) === Parent.prototype)
assert(c instanceof Child)
assert(c instanceof Parent)
}
function Child() {
Parent.call(this)
test(this)
}
function Parent() {}
inherits(Child, Parent)
var c = new Child
test(c)
console.log('ok')

76
node_modules/path-match/package.json generated vendored Normal file
View File

@@ -0,0 +1,76 @@
{
"_args": [
[
"path-match@1.2.4",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "path-match@1.2.4",
"_id": "path-match@1.2.4",
"_inBundle": false,
"_integrity": "sha1-pidH88fgwlFHYml/JEQ1hbCRAOo=",
"_location": "/path-match",
"_phantomChildren": {
"statuses": "1.5.0"
},
"_requested": {
"type": "version",
"registry": true,
"raw": "path-match@1.2.4",
"name": "path-match",
"escapedName": "path-match",
"rawSpec": "1.2.4",
"saveSpec": null,
"fetchSpec": "1.2.4"
},
"_requiredBy": [
"/koa-proxies"
],
"_resolved": "http://192.168.250.101:4873/path-match/-/path-match-1.2.4.tgz",
"_spec": "1.2.4",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"bugs": {
"url": "https://github.com/pillarjs/path-match/issues"
},
"dependencies": {
"http-errors": "~1.4.0",
"path-to-regexp": "^1.0.0"
},
"description": "wrapper around path-to-regexp for easy route parameters",
"devDependencies": {
"istanbul": "^0.4.2",
"mocha": "^2.0.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/pillarjs/path-match#readme",
"keywords": [
"route",
"router",
"routing",
"path",
"regex",
"regexp",
"param",
"params"
],
"license": "MIT",
"name": "path-match",
"repository": {
"type": "git",
"url": "git+https://github.com/pillarjs/path-match.git"
},
"scripts": {
"test": "mocha --reporter spec",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
},
"version": "1.2.4"
}