added express typings

This commit is contained in:
Dolan Miu
2016-03-31 19:04:28 +01:00
parent 8af6262a83
commit c44ff2b28a
6 changed files with 1238 additions and 0 deletions

View File

@ -22,6 +22,18 @@
}, },
"node/node.d.ts": { "node/node.d.ts": {
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8" "commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
},
"express/express.d.ts": {
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
},
"express-serve-static-core/express-serve-static-core.d.ts": {
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
},
"serve-static/serve-static.d.ts": {
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
},
"mime/mime.d.ts": {
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
} }
} }
} }

File diff suppressed because it is too large Load Diff

54
ts/typings/express/express.d.ts vendored Normal file
View File

@ -0,0 +1,54 @@
// Type definitions for Express 4.x
// Project: http://expressjs.com
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* =================== USAGE ===================
import * as express from "express";
var app = express();
=============================================== */
/// <reference path="../serve-static/serve-static.d.ts" />
/// <reference path="../express-serve-static-core/express-serve-static-core.d.ts" />
declare module "express" {
import * as serveStatic from "serve-static";
import * as core from "express-serve-static-core";
/**
* Creates an Express application. The express() function is a top-level function exported by the express module.
*/
function e(): core.Express;
namespace e {
/**
* This is the only built-in middleware function in Express. It serves static files and is based on serve-static.
*/
var static: typeof serveStatic;
export function Router(options?: any): core.Router;
interface Application extends core.Application { }
interface CookieOptions extends core.CookieOptions { }
interface Errback extends core.Errback { }
interface ErrorRequestHandler extends core.ErrorRequestHandler { }
interface Express extends core.Express { }
interface Handler extends core.Handler { }
interface IRoute extends core.IRoute { }
interface IRouter<T> extends core.IRouter<T> { }
interface IRouterMatcher<T> extends core.IRouterMatcher<T> { }
interface MediaType extends core.MediaType { }
interface NextFunction extends core.NextFunction { }
interface Request extends core.Request { }
interface RequestHandler extends core.RequestHandler { }
interface RequestParamHandler extends core.RequestParamHandler { }
export interface Response extends core.Response { }
interface Router extends core.Router { }
interface Send extends core.Send { }
}
export = e;
}

20
ts/typings/mime/mime.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
// Type definitions for mime
// Project: https://github.com/broofa/node-mime
// Definitions by: Jeff Goddard <https://github.com/jedigo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/mime.d.ts
declare module "mime" {
export function lookup(path: string): string;
export function extension(mime: string): string;
export function load(filepath: string): void;
export function define(mimes: Object): void;
interface Charsets {
lookup(mime: string): string;
}
export var charsets: Charsets;
export var default_type: string;
}

View File

@ -0,0 +1,86 @@
// Type definitions for serve-static 1.7.1
// Project: https://github.com/expressjs/serve-static
// Definitions by: Uros Smolnik <https://github.com/urossmolnik/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* =================== USAGE ===================
import * as serveStatic from "serve-static";
app.use(serveStatic("public/ftp", {"index": ["default.html", "default.htm"]}))
=============================================== */
/// <reference path="../express-serve-static-core/express-serve-static-core.d.ts" />
/// <reference path="../mime/mime.d.ts" />
declare module "serve-static" {
import * as express from "express-serve-static-core";
/**
* Create a new middleware function to serve files from within a given root directory.
* The file to serve will be determined by combining req.url with the provided root directory.
* When a file is not found, instead of sending a 404 response, this module will instead call next() to move on to the next middleware, allowing for stacking and fall-backs.
*/
function serveStatic(root: string, options?: {
/**
* Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
* Note this check is done on the path itself without checking if the path actually exists on the disk.
* If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").
* The default value is 'ignore'.
* 'allow' No special treatment for dotfiles
* 'deny' Send a 403 for any request for a dotfile
* 'ignore' Pretend like the dotfile does not exist and call next()
*/
dotfiles?: string;
/**
* Enable or disable etag generation, defaults to true.
*/
etag?: boolean;
/**
* Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.
* The first that exists will be served. Example: ['html', 'htm'].
* The default value is false.
*/
extensions?: string[];
/**
* By default this module will send "index.html" files in response to a request on a directory.
* To disable this set false or to supply a new index pass a string or an array in preferred order.
*/
index?: boolean|string|string[];
/**
* Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
*/
lastModified?: boolean;
/**
* Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
*/
maxAge?: number|string;
/**
* Redirect to trailing "/" when the pathname is a dir. Defaults to true.
*/
redirect?: boolean;
/**
* Function to set custom headers on response. Alterations to the headers need to occur synchronously.
* The function is called as fn(res, path, stat), where the arguments are:
* res the response object
* path the file path that is being sent
* stat the stat object of the file that is being sent
*/
setHeaders?: (res: express.Response, path: string, stat: any) => any;
}): express.Handler;
import * as m from "mime";
namespace serveStatic {
var mime: typeof m;
}
export = serveStatic;
}

4
ts/typings/tsd.d.ts vendored
View File

@ -5,3 +5,7 @@
/// <reference path="chai/chai.d.ts" /> /// <reference path="chai/chai.d.ts" />
/// <reference path="archiver/archiver.d.ts" /> /// <reference path="archiver/archiver.d.ts" />
/// <reference path="node/node.d.ts" /> /// <reference path="node/node.d.ts" />
/// <reference path="express-serve-static-core/express-serve-static-core.d.ts" />
/// <reference path="express/express.d.ts" />
/// <reference path="mime/mime.d.ts" />
/// <reference path="serve-static/serve-static.d.ts" />