From 1dbe3a80d4cafdbe0a5f477b3ece587c2b59ae21 Mon Sep 17 00:00:00 2001 From: TonyYang Date: Thu, 17 Nov 2016 15:22:08 +0800 Subject: [PATCH] Meet types-2.0 style --- response-time/index.d.ts | 43 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/response-time/index.d.ts b/response-time/index.d.ts index 8ab91c86ec..d652e8fa0b 100644 --- a/response-time/index.d.ts +++ b/response-time/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for response-time 2.2.0 +// Type definitions for response-time 2.3.2 // Project: https://github.com/expressjs/response-time -// Definitions by: Uros Smolnik +// Definitions by: Uros Smolnik , TonyYang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + /* =================== USAGE =================== import responseTime = require('response-time'); @@ -11,27 +12,33 @@ =============================================== */ +/// +/// + +import express = require("express"); +import http = require("http"); -import express = require('express'); +export = responseTime; /** * Response time header for node.js * Returns middleware that adds a X-Response-Time header to responses. */ -declare function responseTime(options?: { - /** - * The fixed number of digits to include in the output, which is always in milliseconds, defaults to 3 (ex: 2.300ms). - */ - digits?: number; - /** - * The name of the header to set, defaults to X-Response-Time. - */ - header?: string; - /** - * Boolean to indicate if units of measurement suffix should be added to the output, defaults to true (ex: 2.300ms vs 2.300). - */ - suffix?: boolean; -}): express.RequestHandler; +declare function responseTime(options?: responseTime.ResponseTimeOptions): + (request: http.IncomingMessage, response: http.ServerResponse, callback: (err: any) => void) => any; +declare function responseTime(fn: responseTime.ResponseTimeFunction): + (request: http.IncomingMessage, response: http.ServerResponse, callback: (err: any) => void) => any; -export = responseTime; + +declare namespace responseTime { + export interface ResponseTimeOptions { + digits?: number; + header?: string; + suffix?: boolean; + } + + export interface ResponseTimeFunction { + (request: http.IncomingMessage, response: http.ServerResponse, time: number ): any; + } +}