@amio/micro-cors
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "@amio/micro-cors", | ||
"version": "0.0.6", | ||
"description": "Simple CORS middleware for Zeit's Micro", | ||
"version": "0.0.5", | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"repository": { | ||
"url": "https://github.com/possibilities/micro-cors", | ||
"type": "git" | ||
}, | ||
"author": "Mike Bannister <mikebannister@gmail.com>", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib/index.js" | ||
"repository": "https://github.com/amio/micro-cors", | ||
"contributors": [ | ||
"Mike Bannister <mikebannister@gmail.com>", | ||
"Amio <amio.cn@gmail.com>" | ||
], | ||
"main": "index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "rimraf lib && babel src --out-dir lib", | ||
"test": "ava --verbose src/test.js", | ||
"dev": "ava --verbose --watch src/test.js", | ||
"prepublish": "yarn build", | ||
"lint": "standard", | ||
"pretest": "standard" | ||
"test": "ava --verbose test/*.spec.js", | ||
"dev": "ava --verbose --watch test/*.spec.js", | ||
"prepublishOnly": "npm run test", | ||
"pretest": "npm run lint" | ||
}, | ||
"devDependencies": { | ||
"async-to-gen": "^1.3.2", | ||
"ava": "^0.19.0", | ||
"babel-cli": "^6.24.0", | ||
"babel-polyfill": "^6.23.0", | ||
"babel-preset-latest": "^6.24.0", | ||
"babel-preset-stage-0": "^6.22.0", | ||
"babel-register": "^6.24.0", | ||
"micro": "^7.3.0", | ||
"request-promise": "^4.2.0", | ||
"rimraf": "^2.6.1", | ||
"@babel/cli": "^7.0.0-beta.49", | ||
"@babel/core": "^7.0.0-beta.49", | ||
"@babel/preset-env": "^7.0.0-beta.49", | ||
"ava": "^0.25.0", | ||
"micro": "^9.3.0", | ||
"request": "^2.87.0", | ||
"request-promise": "^4.2.2", | ||
"rimraf": "^2.6.2", | ||
"standard": "^10.0.0", | ||
"test-listen": "^1.0.1" | ||
"test-listen": "^1.1.0" | ||
}, | ||
"ava": { | ||
"failFast": true, | ||
"require": [ | ||
"babel-register" | ||
], | ||
"babel": "inherit" | ||
"failFast": true | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"latest", | ||
"stage-0" | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"shippedProposals": true, | ||
"targets": { | ||
"node": "6.10" | ||
} | ||
} | ||
] | ||
] | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
} | ||
} |
@@ -1,16 +0,15 @@ | ||
# CORS middleware for Micro | ||
# micro-cors | ||
### Summary | ||
Simple [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) middleware for Zeit's [Micro](https://github.com/zeit/micro) | ||
[![CircleCI](https://circleci.com/gh/possibilities/micro-cors.svg?style=svg)](https://circleci.com/gh/possibilities/micro-cors) | ||
[![][npm-badge]][npm-link] | ||
[![Build Status](https://travis-ci.com/amio/micro-cors.svg?branch=master)](https://travis-ci.com/amio/micro-cors) | ||
### Install | ||
## Install | ||
``` | ||
yarn add micro-cors | ||
npm install @amio/micro-cors | ||
``` | ||
### Usage | ||
## Usage | ||
@@ -20,6 +19,7 @@ Basic | ||
```js | ||
const cors = require('micro-cors')() | ||
const handler = (req, res) => send(res, 200, 'ok!') | ||
const micro = require('micro') | ||
const cors = require('micro-cors') | ||
const handler = (req, res) => micro.send(res, 200, 'ok!') | ||
module.exports = cors(handler) | ||
module.exports = cors()(handler) | ||
``` | ||
@@ -30,25 +30,35 @@ | ||
```js | ||
const microCors = require('micro-cors') | ||
const cors = microCors({ allowMethods: ['PUT', 'POST'] }) | ||
const handler = (req, res) => send(res, 200, 'ok!') | ||
const micro = require('micro') | ||
const cors = require('micro-cors') | ||
const handler = (req, res) => micro.send(res, 200, 'ok!') | ||
module.exports = cors(handler) | ||
const opts = { allowMethods: 'PUT,POST' } | ||
module.exports = cors(opts)(handler) | ||
``` | ||
#### Options | ||
### Options | ||
##### `allowMethods` | ||
##### `allowMethods` <String> | ||
default: `['POST','GET','PUT','DELETE','OPTIONS']` | ||
default: `'POST,GET,PUT,PATCH,DELETE,OPTIONS'` | ||
##### `allowHeaders` | ||
##### `allowHeaders` <String> | ||
default: `['X-Requested-With','Access-Control-Allow-Origin','X-HTTP-Method-Override','Content-Type','Authorization','Accept']` | ||
default: `'X-Requested-With,Access-Control-Allow-Origin,X-HTTP-Method-Override,Content-Type,Authorization,Accept'` | ||
##### `maxAge` | ||
##### `exposeHeaders` <String> | ||
default: `undefined` | ||
##### `maxAge` <String> | ||
default: `86400` | ||
##### `origin` | ||
##### `origin` <String> | ||
default: `*` | ||
[npm-badge]: https://img.shields.io/npm/v/@amio/micro-cors.svg | ||
[npm-link]: https://www.npmjs.com/package/@amio/micro-cors |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8856
10
5
203
63
1
1