lambda-api
Advanced tools
Comparing version 0.10.1 to 0.10.2
@@ -30,3 +30,3 @@ import { | ||
lastModified?: boolean | string; | ||
headers?: {}; | ||
headers?: { [key: string]: string }; | ||
cacheControl?: boolean | string; | ||
@@ -40,6 +40,6 @@ private?: boolean; | ||
export declare type Middleware = (req: Request, res: Response, next: Middleware) => void; | ||
export declare type Middleware = (req: Request, res: Response, next: () => void) => void; | ||
export declare type ErrorHandlingMiddleware = (error: Error, req: Request, res: Response, next: ErrorHandlingMiddleware) => void; | ||
export declare type ErrorCallback = (error?: Error) => void; | ||
export declare type HandlerFunction = (req?: Request, res?: Response, next?: NextFunction) => void | {} | Promise<{}>; | ||
export declare type HandlerFunction = (req: Request, res: Response, next?: NextFunction) => void | any | Promise<any>; | ||
export declare type LoggerFunction = (message: string) => void; | ||
@@ -85,3 +85,3 @@ export declare type NextFunction = () => void; | ||
serializers?: { | ||
[name: string]: (req: Request) => {}; | ||
[name: string]: (prop: any) => any; | ||
}; | ||
@@ -106,13 +106,17 @@ stack?: boolean; | ||
id: string; | ||
params: {}; | ||
params: { | ||
[key: string]: string | undefined; | ||
}; | ||
method: string; | ||
path: string; | ||
query: { | ||
[key: string]: string; | ||
[key: string]: string | undefined; | ||
}; | ||
headers: { | ||
[key: string]: string; | ||
[key: string]: string | undefined; | ||
}; | ||
rawHeaders?: {}; | ||
body: {} | string; | ||
rawHeaders?: { | ||
[key: string]: string | undefined; | ||
}; | ||
body: any; | ||
rawBody: string; | ||
@@ -126,4 +130,4 @@ route: ''; | ||
[key: string]: any; | ||
type: 'Bearer' | 'Basic' | 'OAuth' | 'Digest'; | ||
value: string; | ||
type: 'Bearer' | 'Basic' | 'OAuth' | 'Digest' | 'none'; | ||
value: string | null; | ||
}; | ||
@@ -149,2 +153,4 @@ cookies: { | ||
}; | ||
[key: string]: any; | ||
} | ||
@@ -154,2 +160,3 @@ | ||
status(code: number): this; | ||
sendStatus(code: number): void; | ||
header(key: string, value: string): this; | ||
@@ -159,3 +166,3 @@ getHeader(key: string): string; | ||
removeHeader(key: string): this; | ||
getLink(s3Path: string, expires?: number, callback?: (err, data) => void); | ||
getLink(s3Path: string, expires?: number, callback?: ErrorCallback): Promise<string>; | ||
send(body: any): void; | ||
@@ -170,4 +177,4 @@ json(body: any): void; | ||
cors(options: CorsOptions): this; | ||
error(message: string, detail?: any); | ||
error(code: number, message: string, detail?: any); | ||
error(message: string, detail?: any): void; | ||
error(code: number, message: string, detail?: any): void; | ||
cookie(name: string, value: string, options?: CookieOptions): this; | ||
@@ -179,4 +186,4 @@ clearCookie(name: string, options?: CookieOptions): this; | ||
attachment(fileName?: string): this; | ||
download(file: string | Buffer, fileName?: string, options?: FileOptions, callback?: ErrorCallback); | ||
sendFile(file: string | Buffer, options?: FileOptions, callback?: ErrorCallback); | ||
download(file: string | Buffer, fileName?: string, options?: FileOptions, callback?: ErrorCallback): void; | ||
sendFile(file: string | Buffer, options?: FileOptions, callback?: ErrorCallback): Promise<void>; | ||
} | ||
@@ -210,6 +217,6 @@ | ||
use(path: string, ...middleware: Middleware[]); | ||
use(paths: string[], ...middleware: Middleware[]); | ||
use (...middleware: Middleware[]); | ||
use (...errorHandlingMiddleware: ErrorHandlingMiddleware[]); | ||
use(path: string, ...middleware: Middleware[]): void; | ||
use(paths: string[], ...middleware: Middleware[]): void; | ||
use(...middleware: Middleware[]): void; | ||
use(...errorHandlingMiddleware: ErrorHandlingMiddleware[]): void; | ||
@@ -216,0 +223,0 @@ finally(callback: FinallyFunction): void; |
@@ -314,3 +314,3 @@ 'use strict' | ||
response._request._logs.forEach(log => { | ||
console.log(JSON.stringify(this._logger.detail ? // eslint-disable-line no-console | ||
this._logger.logger(JSON.stringify(this._logger.detail ? | ||
this._logger.format(log,response._request,response) : log)) | ||
@@ -325,3 +325,3 @@ }) | ||
) | ||
console.log(JSON.stringify(this._logger.format(access,response._request,response))) // eslint-disable-line no-console | ||
this._logger.logger(JSON.stringify(this._logger.format(access,response._request,response))) | ||
} | ||
@@ -328,0 +328,0 @@ |
@@ -93,2 +93,7 @@ 'use strict' | ||
// Overridable logging function | ||
let logger = cfg.log && typeof cfg.log === 'function' ? | ||
cfg.log : | ||
(...a) => console.log(...a) // eslint-disable-line no-console | ||
// Main logging function | ||
@@ -138,2 +143,3 @@ let log = (level,msg,req,context,custom) => { | ||
stack, | ||
logger, | ||
log, | ||
@@ -140,0 +146,0 @@ format, |
@@ -90,3 +90,3 @@ 'use strict' | ||
// per https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 | ||
this.rawHeaders = this._multiValueSupport ? | ||
this.rawHeaders = this._multiValueSupport && this.app._event.multiValueHeaders !== null ? | ||
Object.keys(this.app._event.multiValueHeaders).reduce((headers,key) => | ||
@@ -93,0 +93,0 @@ Object.assign(headers,{ [key]: UTILS.fromArray(this.app._event.multiValueHeaders[key]) }),{}) |
{ | ||
"name": "lambda-api", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"description": "Lightweight web framework for your serverless applications", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"test-cov": "nyc --reporter=html mocha --check-leaks --recursive", | ||
"test-ci": "nyc npm test && nyc report --reporter=text-lcov | ./node_modules/coveralls/bin/coveralls.js", | ||
"test-ci": "eslint . && nyc npm test && nyc report --reporter=text-lcov | ./node_modules/coveralls/bin/coveralls.js", | ||
"lint": "eslint ." | ||
@@ -49,3 +49,3 @@ }, | ||
"mocha-lcov-reporter": "^1.3.0", | ||
"nyc": "^11.9.0", | ||
"nyc": "^14.1.1", | ||
"sinon": "^4.5.0" | ||
@@ -52,0 +52,0 @@ }, |
Sorry, the diff of this file is too big to display
144827
1755
1372