@compas/server
Advanced tools
Comparing version 0.14.1 to 0.15.0
{ | ||
"name": "@compas/server", | ||
"version": "0.14.1", | ||
"version": "0.15.0", | ||
"description": "Koa server and common middleware", | ||
@@ -24,3 +24,3 @@ "exports": { | ||
"dependencies": { | ||
"@compas/stdlib": "0.14.1", | ||
"@compas/stdlib": "0.15.0", | ||
"@types/formidable": "2.0.6", | ||
@@ -27,0 +27,0 @@ "@types/koa": "2.15.0", |
@@ -38,8 +38,8 @@ /** | ||
* 'Access-Control-Allow-Origin', defaults to the 'Origin' header. | ||
* @property {string|string[]|undefined} [exposeHeaders] 'Access-Control-Expose-Headers' | ||
* @property {string | Array<string> | undefined} [exposeHeaders] 'Access-Control-Expose-Headers' | ||
* @property {string|number|undefined} [maxAge] 'Access-Control-Max-Age' in seconds | ||
* @property {boolean|undefined} [credentials] 'Access-Control-Allow-Credentials' | ||
* @property {string|string[]|undefined} [allowMethods] 'Access-Control-Allow-Methods', | ||
* @property {string | Array<string> | undefined} [allowMethods] 'Access-Control-Allow-Methods', | ||
* defaults to ["DELETE", "GET", "PUT", "POST", "PATCH", "HEAD", "OPTIONS"] | ||
* @property {string|string[]|undefined} [allowHeaders] 'Access-Control-Allow-Headers' | ||
* @property {string | Array<string> | undefined} [allowHeaders] 'Access-Control-Allow-Headers' | ||
*/ | ||
@@ -121,3 +121,3 @@ /** | ||
*/ | ||
exposeHeaders?: string | string[] | undefined; | ||
exposeHeaders?: string | Array<string> | undefined; | ||
/** | ||
@@ -135,8 +135,8 @@ * 'Access-Control-Max-Age' in seconds | ||
*/ | ||
allowMethods?: string | string[] | undefined; | ||
allowMethods?: string | Array<string> | undefined; | ||
/** | ||
* 'Access-Control-Allow-Headers' | ||
*/ | ||
allowHeaders?: string | string[] | undefined; | ||
allowHeaders?: string | Array<string> | undefined; | ||
}; | ||
import Koa from "koa"; |
@@ -51,8 +51,8 @@ import { isProduction } from "@compas/stdlib"; | ||
* 'Access-Control-Allow-Origin', defaults to the 'Origin' header. | ||
* @property {string|string[]|undefined} [exposeHeaders] 'Access-Control-Expose-Headers' | ||
* @property {string | Array<string> | undefined} [exposeHeaders] 'Access-Control-Expose-Headers' | ||
* @property {string|number|undefined} [maxAge] 'Access-Control-Max-Age' in seconds | ||
* @property {boolean|undefined} [credentials] 'Access-Control-Allow-Credentials' | ||
* @property {string|string[]|undefined} [allowMethods] 'Access-Control-Allow-Methods', | ||
* @property {string | Array<string> | undefined} [allowMethods] 'Access-Control-Allow-Methods', | ||
* defaults to ["DELETE", "GET", "PUT", "POST", "PATCH", "HEAD", "OPTIONS"] | ||
* @property {string|string[]|undefined} [allowHeaders] 'Access-Control-Allow-Headers' | ||
* @property {string | Array<string> | undefined} [allowHeaders] 'Access-Control-Allow-Headers' | ||
*/ | ||
@@ -59,0 +59,0 @@ |
@@ -18,5 +18,5 @@ /** | ||
* @param {BodyOptions} [opts={}] Options that will be passed to koa-body | ||
* @returns {import("koa").Middleware} | ||
* @returns {(ctx: import("koa").Context) => Promise<void>} | ||
*/ | ||
export function createBodyParser(opts?: BodyOptions | undefined): import("koa").Middleware; | ||
export function createBodyParser(opts?: BodyOptions | undefined): (ctx: import("koa").Context) => Promise<void>; | ||
export type BodyOptions = { | ||
@@ -68,3 +68,3 @@ /** | ||
*/ | ||
parsedMethods?: string[] | undefined; | ||
parsedMethods?: Array<string> | undefined; | ||
/** | ||
@@ -71,0 +71,0 @@ * Optionally specify multipart |
@@ -21,3 +21,3 @@ import { AppError } from "@compas/stdlib"; | ||
* defaults to '1mb' | ||
* @property {string[]|undefined} [parsedMethods] The HTTP methods which enable body | ||
* @property {Array<string> | undefined} [parsedMethods] The HTTP methods which enable body | ||
* parsing. | ||
@@ -31,3 +31,3 @@ * @property {formidable.Options} [multipartOptions] Optionally specify multipart | ||
/** | ||
* @type {string[]} | ||
* @type {Array<string>} | ||
*/ | ||
@@ -58,3 +58,3 @@ const jsonTypes = [ | ||
* @param {BodyOptions} [opts={}] Options that will be passed to koa-body | ||
* @returns {import("koa").Middleware} | ||
* @returns {(ctx: import("koa").Context) => Promise<void>} | ||
*/ | ||
@@ -82,3 +82,3 @@ export function createBodyParser(opts = {}) { | ||
return async function (ctx, next) { | ||
return async function (ctx) { | ||
let bodyResult; | ||
@@ -158,7 +158,3 @@ // only parse the body on specifically chosen methods | ||
ctx.request.body = bodyResult; | ||
if (typeof next === "function") { | ||
return next(); | ||
} | ||
}; | ||
} |
@@ -6,5 +6,5 @@ /** | ||
* | ||
* @param {import("koa").Middleware[]} middleware | ||
* @param {Array<import("koa").Middleware>} middleware | ||
* @returns {import("koa").Middleware} | ||
*/ | ||
export function compose(middleware: import("koa").Middleware[]): import("koa").Middleware; | ||
export function compose(middleware: Array<import("koa").Middleware>): import("koa").Middleware; |
@@ -13,3 +13,3 @@ /* | ||
* | ||
* @param {import("koa").Middleware[]} middleware | ||
* @param {Array<import("koa").Middleware>} middleware | ||
* @returns {import("koa").Middleware} | ||
@@ -16,0 +16,0 @@ */ |
@@ -100,3 +100,2 @@ import { environment, isStaging } from "@compas/stdlib"; | ||
// eslint-disable-next-line consistent-return | ||
return (ctx, next) => { | ||
@@ -103,0 +102,0 @@ // always set vary Origin Header |
@@ -67,3 +67,4 @@ import { _compasSentryExport, AppError, isProduction } from "@compas/stdlib"; | ||
if (isUnexpectedError) { | ||
// Remove any possible internal details. In explicit 400's for example, info is useful to the caller. | ||
// Remove any possible internal details. In explicit 400's for example, info is useful | ||
// to the caller. | ||
delete formatted.info; | ||
@@ -70,0 +71,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
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
40607
1147
+ Added@compas/stdlib@0.15.0(transitive)
+ Added@types/node@22.7.5(transitive)
- Removed@compas/stdlib@0.14.1(transitive)
- Removed@types/node@22.5.4(transitive)
Updated@compas/stdlib@0.15.0