fastify-cors
Advanced tools
Comparing version 3.0.3 to 4.0.0
133
index.d.ts
@@ -1,77 +0,66 @@ | ||
// Definitions by: Jannik Keye <https://github.com/jannikkeye> | ||
/// <reference types="node" /> | ||
import { Server, IncomingMessage, ServerResponse } from 'http' | ||
import { Http2SecureServer, Http2Server, Http2ServerRequest, Http2ServerResponse } from 'http2' | ||
import { FastifyPlugin } from 'fastify' | ||
import fastify = require('fastify'); | ||
type originCallback = (err: Error | null, allow: boolean) => void; | ||
type originFunction = (origin: string, callback: originCallback) => void; | ||
type originType = string | boolean | RegExp; | ||
type OriginCallback = (err: Error | null, allow: boolean) => void; | ||
type OriginFunction = (origin: string, callback: OriginCallback) => void; | ||
type OriginType = string | boolean | RegExp; | ||
type ValueOrArray<T> = T | ArrayOfValueOrArray<T>; | ||
interface ArrayOfValueOrArray<T> extends Array<ValueOrArray<T>> { } | ||
interface ArrayOfValueOrArray<T> extends Array<ValueOrArray<T>> {} | ||
export interface FastifyCorsOptions { | ||
/** | ||
* Configures the Access-Control-Allow-Origin CORS header. | ||
*/ | ||
origin?: ValueOrArray<OriginType> | OriginFunction; | ||
/** | ||
* Configures the Access-Control-Allow-Credentials CORS header. | ||
* Set to true to pass the header, otherwise it is omitted. | ||
*/ | ||
credentials?: boolean; | ||
/** | ||
* Configures the Access-Control-Expose-Headers CORS header. | ||
* Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range') | ||
* or an array (ex: ['Content-Range', 'X-Content-Range']). | ||
* If not specified, no custom headers are exposed. | ||
*/ | ||
exposedHeaders?: string | string[]; | ||
/** | ||
* Configures the Access-Control-Allow-Headers CORS header. | ||
* Expects a comma-delimited string (ex: 'Content-Type,Authorization') | ||
* or an array (ex: ['Content-Type', 'Authorization']). If not | ||
* specified, defaults to reflecting the headers specified in the | ||
* request's Access-Control-Request-Headers header. | ||
*/ | ||
allowedHeaders?: string | string[]; | ||
/** | ||
* Configures the Access-Control-Allow-Methods CORS header. | ||
* Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: ['GET', 'PUT', 'POST']). | ||
*/ | ||
methods?: string | string[]; | ||
/** | ||
* Configures the Access-Control-Max-Age CORS header. | ||
* Set to an integer to pass the header, otherwise it is omitted. | ||
*/ | ||
maxAge?: number; | ||
/** | ||
* Pass the CORS preflight response to the route handler (default: false). | ||
*/ | ||
preflightContinue?: boolean; | ||
/** | ||
* Provides a status code to use for successful OPTIONS requests, | ||
* since some legacy browsers (IE11, various SmartTVs) choke on 204. | ||
*/ | ||
optionsSuccessStatus?: number; | ||
/** | ||
* Pass the CORS preflight response to the route handler (default: false). | ||
*/ | ||
preflight?: boolean; | ||
/** | ||
* Hide options route from the documentation built using fastify-swagger (default: true). | ||
*/ | ||
hideOptionsRoute?: boolean; | ||
} | ||
declare const fastifyCors: fastify.Plugin< | ||
Server | Http2Server | Http2SecureServer, | ||
IncomingMessage | Http2ServerRequest, | ||
ServerResponse | Http2ServerResponse, | ||
{ | ||
/** | ||
* Configures the Access-Control-Allow-Origin CORS header. | ||
*/ | ||
origin?: ValueOrArray<originType> | originFunction; | ||
/** | ||
* Configures the Access-Control-Allow-Credentials CORS header. | ||
* Set to true to pass the header, otherwise it is omitted. | ||
*/ | ||
credentials?: boolean; | ||
/** | ||
* Configures the Access-Control-Expose-Headers CORS header. | ||
* Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range') | ||
* or an array (ex: ['Content-Range', 'X-Content-Range']). | ||
* If not specified, no custom headers are exposed. | ||
*/ | ||
exposedHeaders?: string | string[]; | ||
/** | ||
* Configures the Access-Control-Allow-Headers CORS header. | ||
* Expects a comma-delimited string (ex: 'Content-Type,Authorization') | ||
* or an array (ex: ['Content-Type', 'Authorization']). If not | ||
* specified, defaults to reflecting the headers specified in the | ||
* request's Access-Control-Request-Headers header. | ||
*/ | ||
allowedHeaders?: string | string[]; | ||
/** | ||
* Configures the Access-Control-Allow-Methods CORS header. | ||
* Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: ['GET', 'PUT', 'POST']). | ||
*/ | ||
methods?: string | string[]; | ||
/** | ||
* Configures the Access-Control-Max-Age CORS header. | ||
* Set to an integer to pass the header, otherwise it is omitted. | ||
*/ | ||
maxAge?: number; | ||
/** | ||
* Pass the CORS preflight response to the route handler (default: false). | ||
*/ | ||
preflightContinue?: boolean; | ||
/** | ||
* Provides a status code to use for successful OPTIONS requests, | ||
* since some legacy browsers (IE11, various SmartTVs) choke on 204. | ||
*/ | ||
optionsSuccessStatus?: number; | ||
/** | ||
* Pass the CORS preflight response to the route handler (default: false). | ||
*/ | ||
preflight?: boolean; | ||
/** | ||
* Hide options route from the documentation built using fastify-swagger (default: true). | ||
*/ | ||
hideOptionsRoute?: boolean; | ||
} | ||
>; | ||
export = fastifyCors; | ||
declare const fastifyCors: FastifyPlugin<FastifyCorsOptions>; | ||
export default fastifyCors; |
@@ -173,4 +173,4 @@ 'use strict' | ||
module.exports = fp(fastifyCors, { | ||
fastify: '>=2.x', | ||
fastify: '3.x', | ||
name: 'fastify-cors' | ||
}) |
{ | ||
"name": "fastify-cors", | ||
"version": "3.0.3", | ||
"version": "4.0.0", | ||
"description": "Fastify CORS", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"unit": "tap test/*.test.js", | ||
"typescript": "tsc --project ./test/types/tsconfig.json", | ||
"typescript": "tsd", | ||
"test": "npm run lint && npm run unit && npm run typescript", | ||
@@ -36,20 +36,19 @@ "coverage": "tap --cov --coverage-report=html test" | ||
"devDependencies": { | ||
"@types/node": "^12.12.7", | ||
"@types/node": "^13.13.4", | ||
"@typescript-eslint/eslint-plugin": "^2.10.0", | ||
"@typescript-eslint/parser": "^2.0.0", | ||
"cors": "^2.8.5", | ||
"fastify": "^2.8.0", | ||
"fastify": "^3.0.0-rc.1", | ||
"standard": "^14.0.2", | ||
"tap": "^12.6.5", | ||
"typescript": "^3.5.3" | ||
"tap": "^14.10.7", | ||
"typescript": "^3.5.3", | ||
"tsd": "^0.11.0" | ||
}, | ||
"dependencies": { | ||
"fastify-plugin": "^1.6.0", | ||
"fastify-plugin": "^2.0.0", | ||
"vary": "^1.1.2" | ||
}, | ||
"greenkeeper": { | ||
"ignore": [ | ||
"tap" | ||
] | ||
"tsd": { | ||
"directory": "test" | ||
} | ||
} |
# fastify-cors | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.org/fastify/fastify-cors.svg?branch=master)](https://travis-ci.org/fastify/fastify-cors) [![Greenkeeper badge](https://badges.greenkeeper.io/fastify/fastify-cors.svg)](https://greenkeeper.io/) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) ![CI workflow](https://github.com/fastify/fastify-cors/workflows/CI%20workflow/badge.svg) | ||
`fastify-cors` enables the use of [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) in a Fastify application. | ||
Supports Fastify versions `>=2.x` | ||
Supports Fastify versions `3.x` | ||
Please refer to [this branch](https://github.com/fastify/fastify-cors/tree/3.x) and related versions for Fastify `^3.x` compatibility. | ||
Please refer to [this branch](https://github.com/fastify/fastify-cors/tree/1.x) and related versions for Fastify `^1.x` compatibility. | ||
@@ -9,0 +10,0 @@ |
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
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
13
67
33156
9
889
1
+ Addedfastify-plugin@2.3.4(transitive)
+ Addedsemver@7.6.3(transitive)
- Removedfastify-plugin@1.6.1(transitive)
- Removedsemver@6.3.1(transitive)
Updatedfastify-plugin@^2.0.0