@lbu/server
Advanced tools
Comparing version 0.0.29 to 0.0.30
{ | ||
"name": "@lbu/server", | ||
"version": "0.0.29", | ||
"version": "0.0.30", | ||
"description": "Koa server and common middleware", | ||
"main": "./index.js", | ||
"exports": "./index.js", | ||
"types": "./index.d.ts", | ||
"type": "module", | ||
@@ -18,6 +19,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@lbu/insight": "0.0.29", | ||
"@lbu/stdlib": "0.0.29", | ||
"@lbu/insight": "0.0.30", | ||
"@lbu/stdlib": "0.0.30", | ||
"keygrip": "1.1.0", | ||
"koa": "2.12.1", | ||
"koa": "2.13.0", | ||
"koa-body": "4.2.0", | ||
@@ -41,3 +42,3 @@ "koa-compose": "4.1.0", | ||
}, | ||
"gitHead": "32fc27ae688e9f9213d08b815118459820a11c17" | ||
"gitHead": "ecb27778bf690ee39bb67eb87769eb6483e6278a" | ||
} |
@@ -11,11 +11,3 @@ import Koa from "koa"; | ||
/** | ||
* Create a new Koa instance with some default middleware | ||
* | ||
* @param {object=} opts | ||
* @param {boolean} [opts.proxy] Trust proxy headers | ||
* @param {boolean} [opts.disableHeaders] Don't handle cors headers | ||
* @param {boolean} [opts.disableHealthRoute] Disable GET /_health | ||
* @param {ErrorHandlerOptions} [opts.errorOptions] Flexible error handling options | ||
* @param {object} opts.headers Argument for defaultHeaders middleware | ||
* @param {CorsOptions} opts.headers.cors Argument for defaultHeaders middleware | ||
* @param {GetAppOptions} [opts] | ||
*/ | ||
@@ -22,0 +14,0 @@ export function getApp(opts = {}) { |
@@ -8,3 +8,3 @@ import { merge } from "@lbu/stdlib"; | ||
* | ||
* @param {object} [opts={}] Options that will be passed to koa-body | ||
* @param {IKoaBodyOptions} [opts={}] Options that will be passed to koa-body | ||
*/ | ||
@@ -11,0 +11,0 @@ export function createBodyParsers(opts = {}) { |
@@ -34,18 +34,2 @@ /* | ||
/** | ||
* @name CorsOptions | ||
* | ||
* @typedef {object} | ||
* @property {string|function(ctx)} [origin] `Access-Control-Allow-Origin`, default is | ||
* request Origin header | ||
* @property {string[]} [exposeHeaders] `Access-Control-Expose-Headers` | ||
* @property {string|number} [maxAge] `Access-Control-Max-Age` in seconds | ||
* @property {boolean} [credentials] `Access-Control-Allow-Credentials` | ||
* @property {string[]} [allowMethods] `Access-Control-Allow-Methods`, | ||
* default is ['GET', 'PUT', 'POST', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'] | ||
* @property {string[]} [allowHeaders] `Access-Control-Allow-Headers` | ||
* @property {boolean} [returnNext] By default, and if false, won't call next, but | ||
* just returns undefined | ||
*/ | ||
/** | ||
* CORS middleware for koa2 | ||
@@ -52,0 +36,0 @@ * |
import { AppError, isNil } from "@lbu/stdlib"; | ||
/** | ||
* @callback CustomErrorHandler | ||
* @param ctx Koa Context | ||
* @param {Error} err | ||
* @returns {boolean} Return truthy when handled or falsey when skipped | ||
*/ | ||
/** | ||
* @callback AppErrorHandler | ||
* @param ctx Koa Context | ||
* @param {string} key | ||
* @param {object} info | ||
* @returns {object} The any data extracted from the key | ||
*/ | ||
/** | ||
* @type CustomErrorHandler | ||
@@ -31,14 +16,2 @@ * Default onError handler that doesn't handle anything | ||
/** | ||
* @name ErrorHandlerOptions | ||
* | ||
* @typedef {object} | ||
* @property {AppErrorHandler} [onAppError] Called to set the initial body when the | ||
* error is an AppError | ||
* @property {CustomErrorHandler} [onError] Called before all others to let the user | ||
* handle their own errors | ||
* @property {boolean} [leakError] Useful on development and staging environments to | ||
* just dump the error to the consumer | ||
*/ | ||
/** | ||
* Handle any upstream errors | ||
@@ -45,0 +18,0 @@ * |
import { isNil } from "@lbu/stdlib"; | ||
/** | ||
* @name SendFile | ||
* | ||
* Compatible with @lbu/store files. Needs either updated_at or last_modified | ||
* | ||
* @typedef {object} | ||
* @property {*} id | ||
* @property {number} content_length | ||
* @property {string} content_type | ||
* @property {Date} [updated_at] | ||
* @property {Date} [last_modified] | ||
*/ | ||
/** | ||
* @name GetStreamFn | ||
* | ||
* @typedef {Function} | ||
* @param {SendFile} fileInfo | ||
* @param {number} [start] | ||
* @param {number} [end] | ||
* @returns {Promise<{ stream: ReadableStream, cacheControl?: string}>} | ||
*/ | ||
/** | ||
* Send any file to the ctx.body | ||
* User is free to set Cache-Control | ||
* | ||
* @param ctx | ||
* @param {SendFile} file | ||
* @param {SendFileItem} file | ||
* @param {GetStreamFn} getStreamFn | ||
@@ -33,0 +7,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
51802
16
1644
1
+ Added@lbu/insight@0.0.30(transitive)
+ Added@lbu/stdlib@0.0.30(transitive)
+ Addedkoa@2.13.0(transitive)
- Removed@lbu/insight@0.0.29(transitive)
- Removed@lbu/stdlib@0.0.29(transitive)
- Removedkoa@2.12.1(transitive)
Updated@lbu/insight@0.0.30
Updated@lbu/stdlib@0.0.30
Updatedkoa@2.13.0