From 804d7addcc0a87eefa56bde192755286e4918263 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 20 Oct 2015 07:48:13 +0500 Subject: [PATCH 1/2] finalhandler: definition of the module has been added --- finalhandler/finalhandler.d.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 finalhandler/finalhandler.d.ts diff --git a/finalhandler/finalhandler.d.ts b/finalhandler/finalhandler.d.ts new file mode 100644 index 000000000..37e931718 --- /dev/null +++ b/finalhandler/finalhandler.d.ts @@ -0,0 +1,20 @@ +// Type definitions for finalhandler +// Project: https://github.com/pillarjs/finalhandler +// Definitions by: Ilya Mochalov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "finalhandler" { + import {ServerRequest, ServerResponse} from "http"; + + export interface Options { + message?: boolean|((err: any, status: number) => string); + onerror?: (err: any, req: ServerRequest, res: ServerResponse) => void; + stacktrace?: boolean; + } + + function finalHandler(req: ServerRequest, res: ServerResponse, options?: Options): (err: any) => void; + + export default finalHandler; +} From bcba8a96fd67c4ae52b504984211efe972a9d082 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 20 Oct 2015 07:48:33 +0500 Subject: [PATCH 2/2] finalhandler: tests have been added --- finalhandler/finalhandler-tests.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 finalhandler/finalhandler-tests.ts diff --git a/finalhandler/finalhandler-tests.ts b/finalhandler/finalhandler-tests.ts new file mode 100644 index 000000000..cb8dc053d --- /dev/null +++ b/finalhandler/finalhandler-tests.ts @@ -0,0 +1,17 @@ +/// + +import {ServerRequest, ServerResponse} from "http"; +import finalHandler from "finalhandler"; + +let req: ServerRequest; +let res: ServerResponse; +let options: { + onerror: (err: any, req: ServerRequest, res: ServerResponse) => void; + message: boolean|((err: any, status: number) => string); + stacktrace: boolean; +}; + +let result: (err: any) => void; + +result = finalHandler(req, res); +result = finalHandler(req, res, options);