@compas/server
Advanced tools
Comparing version 0.0.168 to 0.0.169
@@ -7,4 +7,9 @@ export { getApp } from "./src/app.js"; | ||
export type BodyParserPair = import("./src/middleware/body").BodyParserPair; | ||
export { createBodyParsers, sendFile, session, compose } from "./src/middleware/index.js"; | ||
export { | ||
createBodyParsers, | ||
sendFile, | ||
session, | ||
compose, | ||
} from "./src/middleware/index.js"; | ||
export { closeTestApp, createTestAppAndClient } from "./src/testing.js"; | ||
//# sourceMappingURL=index.d.ts.map | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@compas/server", | ||
"version": "0.0.168", | ||
"version": "0.0.169", | ||
"description": "Koa server and common middleware", | ||
@@ -18,3 +18,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@compas/stdlib": "0.0.168", | ||
"@compas/stdlib": "0.0.169", | ||
"@types/formidable": "1.2.4", | ||
@@ -21,0 +21,0 @@ "@types/koa": "2.13.4", |
140
src/app.d.ts
@@ -62,79 +62,85 @@ /** | ||
*/ | ||
export function getApp(opts?: GetAppOptions | undefined): Koa<Koa.DefaultState, Koa.DefaultContext>; | ||
export function getApp( | ||
opts?: GetAppOptions | undefined, | ||
): Koa<Koa.DefaultState, Koa.DefaultContext>; | ||
export type KoaApplication = ReturnType<typeof getApp>; | ||
export type GetAppOptions = { | ||
/** | ||
* Trust proxy headers | ||
*/ | ||
proxy?: boolean | undefined; | ||
/** | ||
* Don't handle cors headers | ||
*/ | ||
disableHeaders?: boolean | undefined; | ||
/** | ||
* Disable GET /_health | ||
*/ | ||
disableHealthRoute?: boolean | undefined; | ||
/** | ||
* Flexible error handling | ||
* options | ||
*/ | ||
errorOptions?: ErrorHandlerOptions | undefined; | ||
/** | ||
* Argument for defaultHeader middleware | ||
*/ | ||
headers?: HeaderOptions | undefined; | ||
logOptions?: { | ||
/** | ||
* Trust proxy headers | ||
*/ | ||
proxy?: boolean | undefined; | ||
/** | ||
* Don't handle cors headers | ||
*/ | ||
disableHeaders?: boolean | undefined; | ||
/** | ||
* Disable GET /_health | ||
*/ | ||
disableHealthRoute?: boolean | undefined; | ||
/** | ||
* Flexible error handling | ||
* options | ||
*/ | ||
errorOptions?: ErrorHandlerOptions | undefined; | ||
/** | ||
* Argument for defaultHeader middleware | ||
*/ | ||
headers?: HeaderOptions | undefined; | ||
logOptions?: | ||
| { | ||
disableRootEvent?: boolean | undefined; | ||
} | undefined; | ||
} | ||
| undefined; | ||
}; | ||
export type ErrorHandlerOptions = { | ||
/** | ||
* Called to set the initial body | ||
* when the error is an AppError | ||
*/ | ||
onAppError?: ((ctx: Koa.Context, key: string, info: any) => Record<string, any>) | undefined; | ||
/** | ||
* Called | ||
* before any logic, to let the user handle errors. If 'true' is returned, no other | ||
* logic is applied. | ||
*/ | ||
onError?: ((ctx: Koa.Context, err: Error) => boolean) | undefined; | ||
/** | ||
* Adds the stacktrace and originalError to the | ||
* response. Useful on development and staging environments. | ||
*/ | ||
leakError?: boolean | undefined; | ||
/** | ||
* Called to set the initial body | ||
* when the error is an AppError | ||
*/ | ||
onAppError?: | ||
| ((ctx: Koa.Context, key: string, info: any) => Record<string, any>) | ||
| undefined; | ||
/** | ||
* Called | ||
* before any logic, to let the user handle errors. If 'true' is returned, no other | ||
* logic is applied. | ||
*/ | ||
onError?: ((ctx: Koa.Context, err: Error) => boolean) | undefined; | ||
/** | ||
* Adds the stacktrace and originalError to the | ||
* response. Useful on development and staging environments. | ||
*/ | ||
leakError?: boolean | undefined; | ||
}; | ||
export type HeaderOptions = { | ||
cors?: CorsOptions | undefined; | ||
cors?: CorsOptions | undefined; | ||
}; | ||
export type CorsOptions = { | ||
/** | ||
* 'Access-Control-Allow-Origin', defaults to the 'Origin' header. | ||
*/ | ||
origin?: string | ((ctx: Koa.Context) => (string | undefined)) | undefined; | ||
/** | ||
* 'Access-Control-Expose-Headers' | ||
*/ | ||
exposeHeaders?: string | string[] | undefined; | ||
/** | ||
* 'Access-Control-Max-Age' in seconds | ||
*/ | ||
maxAge?: string | number | undefined; | ||
/** | ||
* 'Access-Control-Allow-Credentials' | ||
*/ | ||
credentials?: boolean | undefined; | ||
/** | ||
* 'Access-Control-Allow-Methods', | ||
* defaults to ["DELETE", "GET", "PUT", "POST", "PATCH", "HEAD", "OPTIONS"] | ||
*/ | ||
allowMethods?: string | string[] | undefined; | ||
/** | ||
* 'Access-Control-Allow-Headers' | ||
*/ | ||
allowHeaders?: string | string[] | undefined; | ||
/** | ||
* 'Access-Control-Allow-Origin', defaults to the 'Origin' header. | ||
*/ | ||
origin?: string | ((ctx: Koa.Context) => string | undefined) | undefined; | ||
/** | ||
* 'Access-Control-Expose-Headers' | ||
*/ | ||
exposeHeaders?: string | string[] | undefined; | ||
/** | ||
* 'Access-Control-Max-Age' in seconds | ||
*/ | ||
maxAge?: string | number | undefined; | ||
/** | ||
* 'Access-Control-Allow-Credentials' | ||
*/ | ||
credentials?: boolean | undefined; | ||
/** | ||
* 'Access-Control-Allow-Methods', | ||
* defaults to ["DELETE", "GET", "PUT", "POST", "PATCH", "HEAD", "OPTIONS"] | ||
*/ | ||
allowMethods?: string | string[] | undefined; | ||
/** | ||
* 'Access-Control-Allow-Headers' | ||
*/ | ||
allowHeaders?: string | string[] | undefined; | ||
}; | ||
import Koa from "koa"; | ||
//# sourceMappingURL=app.d.ts.map | ||
//# sourceMappingURL=app.d.ts.map |
@@ -12,23 +12,26 @@ /** | ||
*/ | ||
export function createBodyParsers(bodyOpts?: KoaBodyOptions | undefined, multipartBodyOpts?: formidable.Options | undefined): BodyParserPair; | ||
export function createBodyParsers( | ||
bodyOpts?: KoaBodyOptions | undefined, | ||
multipartBodyOpts?: formidable.Options | undefined, | ||
): BodyParserPair; | ||
export type Middleware = import("koa").Middleware; | ||
export type KoaBodyOptions = { | ||
urlencoded?: boolean | undefined; | ||
json?: boolean | undefined; | ||
text?: boolean | undefined; | ||
encoding?: string | undefined; | ||
/** | ||
* Options for the 'qs' package | ||
*/ | ||
queryString?: object | undefined; | ||
jsonLimit?: string | undefined; | ||
textLimit?: string | undefined; | ||
formLimit?: string | undefined; | ||
parsedMethods?: string[] | undefined; | ||
urlencoded?: boolean | undefined; | ||
json?: boolean | undefined; | ||
text?: boolean | undefined; | ||
encoding?: string | undefined; | ||
/** | ||
* Options for the 'qs' package | ||
*/ | ||
queryString?: object | undefined; | ||
jsonLimit?: string | undefined; | ||
textLimit?: string | undefined; | ||
formLimit?: string | undefined; | ||
parsedMethods?: string[] | undefined; | ||
}; | ||
export type BodyParserPair = { | ||
bodyParser: Middleware; | ||
multipartBodyParser: Middleware; | ||
bodyParser: Middleware; | ||
multipartBodyParser: Middleware; | ||
}; | ||
import formidable from "formidable"; | ||
//# sourceMappingURL=body.d.ts.map | ||
//# sourceMappingURL=body.d.ts.map |
@@ -14,2 +14,2 @@ /** | ||
export type Middleware = import("koa").Middleware; | ||
//# sourceMappingURL=compose.d.ts.map | ||
//# sourceMappingURL=compose.d.ts.map |
@@ -7,3 +7,5 @@ /** | ||
*/ | ||
export function cors(options?: import("../app").CorsOptions | undefined): Function; | ||
//# sourceMappingURL=cors.d.ts.map | ||
export function cors( | ||
options?: import("../app").CorsOptions | undefined, | ||
): Function; | ||
//# sourceMappingURL=cors.d.ts.map |
@@ -9,2 +9,2 @@ /** | ||
export type ErrorHandlerOptions = import("../app").ErrorHandlerOptions; | ||
//# sourceMappingURL=error.d.ts.map | ||
//# sourceMappingURL=error.d.ts.map |
/** | ||
* @param {import("../app").HeaderOptions} [opts] | ||
*/ | ||
export function defaultHeaders(opts?: import("../app").HeaderOptions | undefined): (ctx: any, next: any) => any; | ||
//# sourceMappingURL=headers.d.ts.map | ||
export function defaultHeaders( | ||
opts?: import("../app").HeaderOptions | undefined, | ||
): (ctx: any, next: any) => any; | ||
//# sourceMappingURL=headers.d.ts.map |
@@ -5,2 +5,2 @@ /** | ||
export function healthHandler(): (ctx: any, next: any) => any; | ||
//# sourceMappingURL=health.d.ts.map | ||
//# sourceMappingURL=health.d.ts.map |
@@ -10,2 +10,2 @@ export { createBodyParsers } from "./body.js"; | ||
export { session } from "./session.js"; | ||
//# sourceMappingURL=index.d.ts.map | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,5 +7,8 @@ /** | ||
*/ | ||
export function logMiddleware(app: import("koa"), options: { | ||
export function logMiddleware( | ||
app: import("koa"), | ||
options: { | ||
disableRootEvent?: boolean; | ||
}): (ctx: any, next: any) => Promise<void>; | ||
//# sourceMappingURL=log.d.ts.map | ||
}, | ||
): (ctx: any, next: any) => Promise<void>; | ||
//# sourceMappingURL=log.d.ts.map |
@@ -5,2 +5,2 @@ /** | ||
export function notFoundHandler(): (ctx: any, next: any) => Promise<void>; | ||
//# sourceMappingURL=notFound.d.ts.map | ||
//# sourceMappingURL=notFound.d.ts.map |
@@ -23,7 +23,15 @@ /** | ||
*/ | ||
export function sendFile(ctx: import("koa").Context, file: StoreFile, getStreamFn: GetStreamFn): Promise<void>; | ||
export type GetStreamFn = (file: StoreFile, start?: number | undefined, end?: number | undefined) => Promise<{ | ||
stream: NodeJS.ReadableStream; | ||
cacheControl: string; | ||
export function sendFile( | ||
ctx: import("koa").Context, | ||
file: StoreFile, | ||
getStreamFn: GetStreamFn, | ||
): Promise<void>; | ||
export type GetStreamFn = ( | ||
file: StoreFile, | ||
start?: number | undefined, | ||
end?: number | undefined, | ||
) => Promise<{ | ||
stream: NodeJS.ReadableStream; | ||
cacheControl: string; | ||
}>; | ||
//# sourceMappingURL=sendFile.d.ts.map | ||
//# sourceMappingURL=sendFile.d.ts.map |
@@ -19,8 +19,13 @@ /** | ||
*/ | ||
export function session(app: import("../app").KoaApplication, opts: Partial<koaSession.opts & { | ||
renew: number | boolean; | ||
keepPublicCookie?: boolean; | ||
}>): Middleware; | ||
export function session( | ||
app: import("../app").KoaApplication, | ||
opts: Partial< | ||
koaSession.opts & { | ||
renew: number | boolean; | ||
keepPublicCookie?: boolean; | ||
} | ||
>, | ||
): Middleware; | ||
export type Middleware = import("koa").Middleware; | ||
import koaSession from "koa-session"; | ||
//# sourceMappingURL=session.d.ts.map | ||
//# sourceMappingURL=session.d.ts.map |
@@ -11,3 +11,6 @@ /** | ||
*/ | ||
export function createTestAppAndClient(app: import("./app").KoaApplication, axios: import("axios").AxiosInstance): Promise<void>; | ||
export function createTestAppAndClient( | ||
app: import("./app").KoaApplication, | ||
axios: import("axios").AxiosInstance, | ||
): Promise<void>; | ||
/** | ||
@@ -21,3 +24,5 @@ * Close the test app as created by `createTestAppAndClient`. | ||
*/ | ||
export function closeTestApp(app: import("./app").KoaApplication): Promise<void>; | ||
//# sourceMappingURL=testing.d.ts.map | ||
export function closeTestApp( | ||
app: import("./app").KoaApplication, | ||
): Promise<void>; | ||
//# sourceMappingURL=testing.d.ts.map |
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
1309
48594
+ Added@compas/stdlib@0.0.169(transitive)
+ Addedgopd@1.2.0(transitive)
- Removed@compas/stdlib@0.0.168(transitive)
- Removedgopd@1.1.0(transitive)
Updated@compas/stdlib@0.0.169