mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
docs:更新文档
This commit is contained in:
73
node_modules/@koa/cors/History.md
generated
vendored
Normal file
73
node_modules/@koa/cors/History.md
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
3.1.0 / 2020-05-17
|
||||
==================
|
||||
|
||||
**features**
|
||||
* [[`013662a`](http://github.com/koajs/cors/commit/013662ae1ab65c4af230c17dfa1044609502b15b)] - feat: add support for using a function to determine whether or not to allow credentials. (#68) (mcohen75 <<mcohen75@gmail.com>>)
|
||||
|
||||
**others**
|
||||
* [[`da84dec`](http://github.com/koajs/cors/commit/da84dec7fa16af95d157a549bd473e7bfa4aa152)] - docs: update install script (dead-horse <<dead_horse@qq.com>>)
|
||||
* [[`eba3b44`](http://github.com/koajs/cors/commit/eba3b446055bd14b86d19dfc81d8ed5f83a8a534)] - chore: ES6 Object spread (#66) (Alpha <<AlphaWong@users.noreply.github.com>>)
|
||||
|
||||
3.0.0 / 2019-03-11
|
||||
==================
|
||||
|
||||
**others**
|
||||
* [[`369d31d`](http://github.com/koajs/cors/commit/369d31db7835ed344011706f9506d45a44638017)] - refactor: use async function, support options.origin return promise (#59) (Yiyu He <<dead_horse@qq.com>>)
|
||||
|
||||
2.2.3 / 2018-12-19
|
||||
==================
|
||||
|
||||
**fixes**
|
||||
* [[`12ae730`](http://github.com/koajs/cors/commit/12ae7306e8055322e6c5d29319330da52ba0e126)] - fix: set `Vary: Origin` header on error responses (#55) (Erik Fried <<erik.fried@aftonbladet.se>>)
|
||||
|
||||
2.2.2 / 2018-07-11
|
||||
==================
|
||||
|
||||
**others**
|
||||
* [[`019ec40`](http://github.com/koajs/cors/commit/019ec403be573177e8ed6ad3ef4077b82b5ea934)] - travis: test node@10 and drop test node@4 (#51) (fengmk2 <<fengmk2@gmail.com>>)
|
||||
* [[`6e22833`](http://github.com/koajs/cors/commit/6e22833ce125ca334b68980372065867eda892b0)] - doc: update outdated options doc (Xingan Wang <<wangxgwxg@gmail.com>>)
|
||||
* [[`c982530`](http://github.com/koajs/cors/commit/c9825308ce1c76810468bdf5a404b838206fba22)] - travis: test node@8 (jongleberry <<me@jongleberry.com>>)
|
||||
* [[`b4f65b3`](http://github.com/koajs/cors/commit/b4f65b39b558b870521e6613aee58898e88196f9)] - npm: remove tag (jongleberry <<me@jongleberry.com>>)
|
||||
* [[`878ae9b`](http://github.com/koajs/cors/commit/878ae9b0c99fb6da8d3840e502d4968a65089e28)] - package: rename to @koa/cors (jongleberry <<me@jongleberry.com>>)
|
||||
|
||||
2.2.1 / 2017-02-12
|
||||
==================
|
||||
|
||||
* fix: always set "Vary: Origin" header (#31)
|
||||
|
||||
2.2.0 / 2016-09-26
|
||||
==================
|
||||
|
||||
* feat: add PATCH to default methods
|
||||
|
||||
2.1.1 / 2016-05-14
|
||||
==================
|
||||
|
||||
* fix: keepHeadersOnError won't affect OPTIONS request (#17)
|
||||
|
||||
2.1.0 / 2016-04-29
|
||||
==================
|
||||
|
||||
* feat: Keep headers after an error (#13)
|
||||
* chore: use eslint instead of jshint (#10)
|
||||
* test: use codecov instead of coveralls
|
||||
|
||||
2.0.0 / 2016-02-20
|
||||
==================
|
||||
|
||||
* chore: make node engines >= 4.3.1
|
||||
* doc: update example
|
||||
* test: only test on node 4+
|
||||
* refactor: src,test: update to (ctx, next) -> Promise middleware contract
|
||||
* chore: base on koa@2
|
||||
|
||||
1.0.1 / 2015-02-11
|
||||
==================
|
||||
|
||||
* fix: make more spec-compliant
|
||||
|
||||
1.0.0 / 2015-02-09
|
||||
==================
|
||||
|
||||
* first release
|
||||
21
node_modules/@koa/cors/LICENSE
generated
vendored
Normal file
21
node_modules/@koa/cors/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
Copyright (c) 2015 - 2018 koajs and other contributors
|
||||
|
||||
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.
|
||||
65
node_modules/@koa/cors/README.md
generated
vendored
Normal file
65
node_modules/@koa/cors/README.md
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
@koa/cors
|
||||
=======
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![build status][travis-image]][travis-url]
|
||||
[![Test coverage][codecov-image]][codecov-url]
|
||||
[![David deps][david-image]][david-url]
|
||||
[![npm download][download-image]][download-url]
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/@koa/cors.svg?style=flat-square
|
||||
[npm-url]: https://npmjs.org/package/@koa/cors
|
||||
[travis-image]: https://img.shields.io/travis/koajs/cors.svg?style=flat-square
|
||||
[travis-url]: https://travis-ci.org/koajs/cors
|
||||
[codecov-image]: https://codecov.io/github/koajs/cors/coverage.svg?branch=v2.x
|
||||
[codecov-url]: https://codecov.io/github/koajs/cors?branch=v2.x
|
||||
[david-image]: https://img.shields.io/david/koajs/cors.svg?style=flat-square
|
||||
[david-url]: https://david-dm.org/koajs/cors
|
||||
[download-image]: https://img.shields.io/npm/dm/@koa/cors.svg?style=flat-square
|
||||
[download-url]: https://npmjs.org/package/@koa/cors
|
||||
|
||||
[Cross-Origin Resource Sharing(CORS)](https://developer.mozilla.org/en/docs/Web/HTTP/Access_control_CORS) for koa
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install @koa/cors --save
|
||||
```
|
||||
|
||||
## Quick start
|
||||
|
||||
Enable cors with default options:
|
||||
|
||||
- origin: request Origin header
|
||||
- allowMethods: GET,HEAD,PUT,POST,DELETE,PATCH
|
||||
|
||||
```js
|
||||
const Koa = require('koa');
|
||||
const cors = require('@koa/cors');
|
||||
|
||||
const app = new Koa();
|
||||
app.use(cors());
|
||||
```
|
||||
|
||||
## cors(options)
|
||||
|
||||
```js
|
||||
/**
|
||||
* CORS middleware
|
||||
*
|
||||
* @param {Object} [options]
|
||||
* - {String|Function(ctx)} origin `Access-Control-Allow-Origin`, default is request Origin header
|
||||
* - {String|Array} allowMethods `Access-Control-Allow-Methods`, default is 'GET,HEAD,PUT,POST,DELETE,PATCH'
|
||||
* - {String|Array} exposeHeaders `Access-Control-Expose-Headers`
|
||||
* - {String|Array} allowHeaders `Access-Control-Allow-Headers`
|
||||
* - {String|Number} maxAge `Access-Control-Max-Age` in seconds
|
||||
* - {Boolean|Function(ctx)} credentials `Access-Control-Allow-Credentials`, default is false.
|
||||
* - {Boolean} keepHeadersOnError Add set headers to `err.header` if an error is thrown
|
||||
* @return {Function} cors middleware
|
||||
* @api public
|
||||
*/
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE)
|
||||
147
node_modules/@koa/cors/index.js
generated
vendored
Normal file
147
node_modules/@koa/cors/index.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
'use strict';
|
||||
|
||||
const vary = require('vary');
|
||||
|
||||
/**
|
||||
* CORS middleware
|
||||
*
|
||||
* @param {Object} [options]
|
||||
* - {String|Function(ctx)} origin `Access-Control-Allow-Origin`, default is request Origin header
|
||||
* - {String|Array} allowMethods `Access-Control-Allow-Methods`, default is 'GET,HEAD,PUT,POST,DELETE,PATCH'
|
||||
* - {String|Array} exposeHeaders `Access-Control-Expose-Headers`
|
||||
* - {String|Array} allowHeaders `Access-Control-Allow-Headers`
|
||||
* - {String|Number} maxAge `Access-Control-Max-Age` in seconds
|
||||
* - {Boolean} credentials `Access-Control-Allow-Credentials`
|
||||
* - {Boolean} keepHeadersOnError Add set headers to `err.header` if an error is thrown
|
||||
* @return {Function} cors middleware
|
||||
* @api public
|
||||
*/
|
||||
module.exports = function(options) {
|
||||
const defaults = {
|
||||
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
|
||||
};
|
||||
|
||||
options = {
|
||||
...defaults,
|
||||
...options,
|
||||
};
|
||||
|
||||
if (Array.isArray(options.exposeHeaders)) {
|
||||
options.exposeHeaders = options.exposeHeaders.join(',');
|
||||
}
|
||||
|
||||
if (Array.isArray(options.allowMethods)) {
|
||||
options.allowMethods = options.allowMethods.join(',');
|
||||
}
|
||||
|
||||
if (Array.isArray(options.allowHeaders)) {
|
||||
options.allowHeaders = options.allowHeaders.join(',');
|
||||
}
|
||||
|
||||
if (options.maxAge) {
|
||||
options.maxAge = String(options.maxAge);
|
||||
}
|
||||
|
||||
options.keepHeadersOnError = options.keepHeadersOnError === undefined || !!options.keepHeadersOnError;
|
||||
|
||||
return async function cors(ctx, next) {
|
||||
// If the Origin header is not present terminate this set of steps.
|
||||
// The request is outside the scope of this specification.
|
||||
const requestOrigin = ctx.get('Origin');
|
||||
|
||||
// Always set Vary header
|
||||
// https://github.com/rs/cors/issues/10
|
||||
ctx.vary('Origin');
|
||||
|
||||
if (!requestOrigin) return await next();
|
||||
|
||||
let origin;
|
||||
if (typeof options.origin === 'function') {
|
||||
origin = options.origin(ctx);
|
||||
if (origin instanceof Promise) origin = await origin;
|
||||
if (!origin) return await next();
|
||||
} else {
|
||||
origin = options.origin || requestOrigin;
|
||||
}
|
||||
|
||||
let credentials;
|
||||
if (typeof options.credentials === 'function') {
|
||||
credentials = options.credentials(ctx);
|
||||
if (credentials instanceof Promise) credentials = await credentials;
|
||||
} else {
|
||||
credentials = !!options.credentials;
|
||||
}
|
||||
|
||||
const headersSet = {};
|
||||
|
||||
function set(key, value) {
|
||||
ctx.set(key, value);
|
||||
headersSet[key] = value;
|
||||
}
|
||||
|
||||
if (ctx.method !== 'OPTIONS') {
|
||||
// Simple Cross-Origin Request, Actual Request, and Redirects
|
||||
set('Access-Control-Allow-Origin', origin);
|
||||
|
||||
if (credentials === true) {
|
||||
set('Access-Control-Allow-Credentials', 'true');
|
||||
}
|
||||
|
||||
if (options.exposeHeaders) {
|
||||
set('Access-Control-Expose-Headers', options.exposeHeaders);
|
||||
}
|
||||
|
||||
if (!options.keepHeadersOnError) {
|
||||
return await next();
|
||||
}
|
||||
try {
|
||||
return await next();
|
||||
} catch (err) {
|
||||
const errHeadersSet = err.headers || {};
|
||||
const varyWithOrigin = vary.append(errHeadersSet.vary || errHeadersSet.Vary || '', 'Origin');
|
||||
delete errHeadersSet.Vary;
|
||||
|
||||
err.headers = {
|
||||
...errHeadersSet,
|
||||
...headersSet,
|
||||
...{ vary: varyWithOrigin },
|
||||
};
|
||||
throw err;
|
||||
}
|
||||
} else {
|
||||
// Preflight Request
|
||||
|
||||
// If there is no Access-Control-Request-Method header or if parsing failed,
|
||||
// do not set any additional headers and terminate this set of steps.
|
||||
// The request is outside the scope of this specification.
|
||||
if (!ctx.get('Access-Control-Request-Method')) {
|
||||
// this not preflight request, ignore it
|
||||
return await next();
|
||||
}
|
||||
|
||||
ctx.set('Access-Control-Allow-Origin', origin);
|
||||
|
||||
if (credentials === true) {
|
||||
ctx.set('Access-Control-Allow-Credentials', 'true');
|
||||
}
|
||||
|
||||
if (options.maxAge) {
|
||||
ctx.set('Access-Control-Max-Age', options.maxAge);
|
||||
}
|
||||
|
||||
if (options.allowMethods) {
|
||||
ctx.set('Access-Control-Allow-Methods', options.allowMethods);
|
||||
}
|
||||
|
||||
let allowHeaders = options.allowHeaders;
|
||||
if (!allowHeaders) {
|
||||
allowHeaders = ctx.get('Access-Control-Request-Headers');
|
||||
}
|
||||
if (allowHeaders) {
|
||||
ctx.set('Access-Control-Allow-Headers', allowHeaders);
|
||||
}
|
||||
|
||||
ctx.status = 204;
|
||||
}
|
||||
};
|
||||
};
|
||||
83
node_modules/@koa/cors/package.json
generated
vendored
Normal file
83
node_modules/@koa/cors/package.json
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@koa/cors@3.1.0",
|
||||
"J:\\Github\\CURD-TS"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "@koa/cors@3.1.0",
|
||||
"_id": "@koa/cors@3.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-YYuwc0OM/b0+vQ5kinbjO4Tzo7I=",
|
||||
"_location": "/@koa/cors",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@koa/cors@3.1.0",
|
||||
"name": "@koa/cors",
|
||||
"escapedName": "@koa%2fcors",
|
||||
"scope": "@koa",
|
||||
"rawSpec": "3.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/vite"
|
||||
],
|
||||
"_resolved": "http://192.168.250.101:4873/@koa%2fcors/-/cors-3.1.0.tgz",
|
||||
"_spec": "3.1.0",
|
||||
"_where": "J:\\Github\\CURD-TS",
|
||||
"author": {
|
||||
"name": "fengmk2",
|
||||
"email": "fengmk2@gmail.com",
|
||||
"url": "http://fengmk2.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/koajs/cors/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"vary": "^1.1.2"
|
||||
},
|
||||
"description": "Cross-Origin Resource Sharing(CORS) for koa",
|
||||
"devDependencies": {
|
||||
"autod": "*",
|
||||
"eslint": "^5.15.1",
|
||||
"eslint-config-egg": "^7.1.0",
|
||||
"istanbul": "*",
|
||||
"koa": "^2.5.1",
|
||||
"mocha": "3",
|
||||
"supertest": "^3.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/koajs/cors",
|
||||
"keywords": [
|
||||
"cors",
|
||||
"koa-cors",
|
||||
"Cross-Origin Resource Sharing",
|
||||
"@koa/cors",
|
||||
"koa",
|
||||
"koajs"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "@koa/cors",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/koajs/cors.git"
|
||||
},
|
||||
"scripts": {
|
||||
"autod": "autod -w --prefix '^'",
|
||||
"ci": "npm run lint && npm run test-cov",
|
||||
"lint": "eslint index.js test",
|
||||
"test": "NODE_ENV=test mocha --check-leaks -R spec -t 5000 test/*.test.js",
|
||||
"test-cov": "NODE_ENV=test istanbul cover _mocha -- --check-leaks -t 5000 test/*.test.js"
|
||||
},
|
||||
"version": "3.1.0"
|
||||
}
|
||||
Reference in New Issue
Block a user