@fluvial/cors
Advanced tools
Comparing version 0.4.7 to 0.5.0
import type { Request, Response } from 'fluvial'; | ||
export declare function cors(options?: CorsOptions): (req: Request, res: Response) => 'next' | void; | ||
export declare function cors(options?: CorsOptions): (req: Request, res: Response) => "next" | void; | ||
export interface CorsOptions { | ||
@@ -4,0 +4,0 @@ continuePreflight?: boolean; |
{ | ||
"name": "@fluvial/cors", | ||
"version": "0.4.7", | ||
"version": "0.5.0", | ||
"main": "dist/index.js", | ||
@@ -31,6 +31,4 @@ "files": [ | ||
"devDependencies": { | ||
"@types/node": "^20.4.1", | ||
"@vitest/coverage-v8": "^0.33.0", | ||
"typescript": "^5.1.6", | ||
"vitest": "^0.33.0" | ||
"@types/node": "^22.4.1", | ||
"typescript": "^5.5.4" | ||
}, | ||
@@ -41,7 +39,8 @@ "peerDependencies": { | ||
"scripts": { | ||
"compile": "tsc -b", | ||
"test": "vitest", | ||
"test:coverage": "pnpm test -- --coverage", | ||
"prepublish": "pnpm test run && pnpm compile" | ||
"ex": "pnpm tsx", | ||
"compile": "tsc --project tsconfig.src.json", | ||
"test": "pnpm ex --tsconfig=tsconfig.test.json --test src/**/*.test.ts", | ||
"test:coverage": "pnpm ex --tsconfig=tsconfig.test.json --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=dist/lcov.info --test-reporter=tap --test-reporter-destination=dist/tap.info src/**/*.test.ts", | ||
"prepublish": "pnpm test && pnpm compile" | ||
} | ||
} |
@@ -0,0 +0,0 @@ # `@fluvial/cors` |
@@ -1,4 +0,4 @@ | ||
import assert from 'node:assert'; | ||
import { describe, test } from 'node:test'; | ||
import { equal } from 'node:assert'; | ||
import type { Request, Response } from 'fluvial'; | ||
import { describe, test, expect } from 'vitest'; | ||
import { cors } from '../index.js'; | ||
@@ -34,7 +34,7 @@ | ||
expect(res.headers['Access-Control-Allow-Origin']).toEqual('*'); | ||
expect(result).toEqual('next'); | ||
expect(reportedStatusCode).toEqual(-1); | ||
expect(responseSent).toEqual(false); | ||
expect(responsePayload).toBe(null); | ||
equal(res.headers['Access-Control-Allow-Origin'], '*'); | ||
equal(result, 'next'); | ||
equal(reportedStatusCode, -1); | ||
equal(responseSent, false); | ||
equal(responsePayload, null); | ||
}); | ||
@@ -68,8 +68,8 @@ | ||
expect(result).toEqual(undefined); | ||
expect(reportedStatusCode).toEqual(204); | ||
expect('Content-Length' in res.headers).toEqual(true); | ||
expect(res.headers['Content-Length']).toEqual('0'); | ||
expect(responseSent).toEqual(true); | ||
expect(responsePayload).toEqual(undefined); | ||
equal(result, undefined); | ||
equal(reportedStatusCode, 204); | ||
equal('Content-Length' in res.headers, true); | ||
equal(res.headers['Content-Length'], '0'); | ||
equal(responseSent, true); | ||
equal(responsePayload, undefined); | ||
}); | ||
@@ -105,6 +105,6 @@ | ||
expect(result).toEqual('next'); | ||
expect(reportedStatusCode).toEqual(-1); | ||
expect(responseSent).toEqual(false); | ||
expect(responsePayload).toBe(null); | ||
equal(result, 'next'); | ||
equal(reportedStatusCode, -1); | ||
equal(responseSent, false); | ||
equal(responsePayload, null); | ||
}); | ||
@@ -142,6 +142,6 @@ | ||
expect(result).toEqual(undefined); | ||
expect(responseSent).toEqual(true); | ||
expect(reportedStatusCode).toEqual(406); | ||
expect(responsePayload).toEqual(undefined); | ||
equal(result, undefined); | ||
equal(responseSent, true); | ||
equal(reportedStatusCode, 406); | ||
equal(responsePayload, undefined); | ||
}); | ||
@@ -178,6 +178,6 @@ | ||
expect(result).toEqual('next'); | ||
expect(reportedStatusCode).toEqual(-1); | ||
expect(responseSent).toEqual(false); | ||
expect(responsePayload).toBe(null); | ||
equal(result, 'next'); | ||
equal(reportedStatusCode, -1); | ||
equal(responseSent, false); | ||
equal(responsePayload, null); | ||
}); | ||
@@ -213,7 +213,7 @@ | ||
expect(result).toEqual(undefined); | ||
expect(reportedStatusCode).toEqual(405); | ||
expect(responseSent).toEqual(true); | ||
expect(responsePayload).toBe(undefined); | ||
equal(result, undefined); | ||
equal(reportedStatusCode, 405); | ||
equal(responseSent, true); | ||
equal(responsePayload, undefined); | ||
}); | ||
}); |
@@ -0,0 +0,0 @@ import type { Request, Response } from 'fluvial'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
70641
2
13
459