refactor: upgraded @types/cors

This commit is contained in:
Stijn Taelemans 2021-02-10 10:51:07 +01:00 committed by Joachim Van Herwegen
parent 38b1c98cb6
commit 9b6eab27bc
3 changed files with 14 additions and 10 deletions

9
package-lock.json generated
View File

@ -1176,12 +1176,9 @@
"dev": true "dev": true
}, },
"@types/cors": { "@types/cors": {
"version": "2.8.8", "version": "2.8.9",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.8.tgz", "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.9.tgz",
"integrity": "sha512-fO3gf3DxU2Trcbr75O7obVndW/X5k8rJNZkLXlQWStTHhP71PkRqjwPIEI0yMnJdg9R9OasjU+Bsr+Hr1xy/0w==", "integrity": "sha512-zurD1ibz21BRlAOIKP8yhrxlqKx6L9VCwkB5kMiP6nZAhoF5MvC7qS1qPA7nRcr1GJolfkQC7/EAL4hdYejLtg=="
"requires": {
"@types/express": "*"
}
}, },
"@types/express": { "@types/express": {
"version": "4.17.8", "version": "4.17.8",

View File

@ -78,7 +78,7 @@
"@solid/identity-token-verifier": "^0.5.1", "@solid/identity-token-verifier": "^0.5.1",
"@types/arrayify-stream": "^1.0.0", "@types/arrayify-stream": "^1.0.0",
"@types/async-lock": "^1.1.2", "@types/async-lock": "^1.1.2",
"@types/cors": "^2.8.6", "@types/cors": "^2.8.9",
"@types/express": "^4.17.6", "@types/express": "^4.17.6",
"@types/mime-types": "^2.1.0", "@types/mime-types": "^2.1.0",
"@types/n3": "^1.4.4", "@types/n3": "^1.4.4",

View File

@ -1,6 +1,5 @@
import cors from 'cors'; import cors from 'cors';
import type { CorsOptions } from 'cors'; import type { CorsOptions, CorsRequest } from 'cors';
import type { RequestHandler } from 'express';
import type { HttpHandlerInput } from '../HttpHandler'; import type { HttpHandlerInput } from '../HttpHandler';
import { HttpHandler } from '../HttpHandler'; import { HttpHandler } from '../HttpHandler';
@ -30,7 +29,15 @@ interface SimpleCorsOptions {
* Full details: https://solid.github.io/specification/protocol#cors-server * Full details: https://solid.github.io/specification/protocol#cors-server
*/ */
export class CorsHandler extends HttpHandler { export class CorsHandler extends HttpHandler {
private readonly corsHandler: RequestHandler; private readonly corsHandler: (
req: CorsRequest,
res: {
statusCode?: number;
setHeader: (key: string, value: string) => any;
end: () => any;
},
next: (err?: any) => any,
) => void;
public constructor(options: SimpleCorsOptions = {}) { public constructor(options: SimpleCorsOptions = {}) {
super(); super();