From 5e202a9846bae747fe94bb945efefe137821320f Mon Sep 17 00:00:00 2001 From: VILIC VANE Date: Sun, 10 Aug 2014 21:34:48 +0800 Subject: [PATCH 1/2] add res.sendFile and mark res.sendfile as deprecated --- express/express.d.ts | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/express/express.d.ts b/express/express.d.ts index d9551e22b..439adc141 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -485,14 +485,18 @@ declare module "express" { * * Options: * - * - `maxAge` defaulting to 0 - * - `root` root directory for relative filenames + * - `maxAge` defaulting to 0 (can be string converted by `ms`) + * - `root` root directory for relative filenames + * - `headers` object of headers to serve with file + * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them + * + * Other options are passed along to `send`. * * Examples: * - * The following example illustrates how `res.sendfile()` may + * The following example illustrates how `res.sendFile()` may * be used as an alternative for the `static()` middleware for - * dynamic situations. The code backing `res.sendfile()` is actually + * dynamic situations. The code backing `res.sendFile()` is actually * the same code, so HTTP cache support etc is identical. * * app.get('/user/:uid/photos/:file', function(req, res){ @@ -501,16 +505,35 @@ declare module "express" { * * req.user.mayViewFilesFrom(uid, function(yes){ * if (yes) { - * res.sendfile('/uploads/' + uid + '/' + file); + * res.sendFile('/uploads/' + uid + '/' + file); * } else { * res.send(403, 'Sorry! you cant see that.'); * } * }); * }); + * + * @api public + */ + sendFile(path: string): void; + sendFile(path: string, options: any): void; + sendFile(path: string, fn: Errback): void; + sendFile(path: string, options: any, fn: Errback): void; + + /** + * deprecated, use sendFile instead. */ sendfile(path: string): void; + /** + * deprecated, use sendFile instead. + */ sendfile(path: string, options: any): void; + /** + * deprecated, use sendFile instead. + */ sendfile(path: string, fn: Errback): void; + /** + * deprecated, use sendFile instead. + */ sendfile(path: string, options: any, fn: Errback): void; /** From d9aaf6bd95900a6e1083190cdab3f2e2ef069df6 Mon Sep 17 00:00:00 2001 From: vvakame Date: Sat, 23 Aug 2014 15:05:38 +0900 Subject: [PATCH 2/2] resolve duplicate for #2676 --- express/express.d.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/express/express.d.ts b/express/express.d.ts index 7f12a9f81..d5d48308f 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -3,7 +3,7 @@ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped -/* =================== USAGE =================== +/* =================== USAGE =================== import express = require('express'); var app = express(); @@ -522,11 +522,6 @@ declare module "express" { /** * deprecated, use sendFile instead. */ - sendFile(path: string): void; - sendFile(path: string, options: any): void; - sendFile(path: string, fn: Errback): void; - sendFile(path: string, options: any, fn: Errback): void; - sendfile(path: string): void; /** * deprecated, use sendFile instead. @@ -1073,4 +1068,3 @@ declare module "express" { export = e; } -