Skip to content

Commit 59ec9b0

Browse files
committed
- Added definitions from typescript samples directories
0 parents  commit 59ec9b0

File tree

3 files changed

+1214
-0
lines changed

3 files changed

+1214
-0
lines changed

express2.d.ts

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/// <reference path="node.d.ts" />
2+
3+
declare module "express" {
4+
export function createServer(): ExpressServer;
5+
export function static(path: string): any;
6+
import http = module("http");
7+
export var listen;
8+
9+
// Connect middleware
10+
export function bodyParser(options?:any): (req: ExpressServerRequest, res: ExpressServerResponse, next) =>void;
11+
export function errorHandler(opts?:any): (req: ExpressServerRequest, res: ExpressServerResponse, next) =>void;
12+
export function methodOverride(): (req: ExpressServerRequest, res: ExpressServerResponse, next) =>void;
13+
14+
export interface ExpressSettings {
15+
env?: string;
16+
views?: string;
17+
}
18+
19+
export interface ExpressServer {
20+
set(name: string): any;
21+
set(name: string, val: any): any;
22+
enable(name: string): ExpressServer;
23+
disable(name: string): ExpressServer;
24+
enabled(name: string): bool;
25+
disabled(name: string): bool;
26+
configure(env: string, callback: () => void): ExpressServer;
27+
configure(env: string, env2: string, callback: () => void ): ExpressServer;
28+
configure(callback: () => void): ExpressServer;
29+
settings: ExpressSettings;
30+
engine(ext: string, callback: any): void;
31+
param(param: Function): ExpressServer;
32+
param(name: string, callback: Function): ExpressServer;
33+
param(name: string, expressParam: any): ExpressServer;
34+
param(name: any[], callback: Function): ExpressServer;
35+
get(name: string): any;
36+
get(path: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse) => void ): void;
37+
get(path: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse) => void ): void;
38+
get(path: string, callbacks: any, callback: () => void ): void;
39+
post(path: string, handler: (req: ExpressServerRequest, res: ExpressServerResponse) => void ): void;
40+
post(path: RegExp, handler: (req: ExpressServerRequest, res: ExpressServerResponse) => void ): void;
41+
post(path: string, callbacks: any, callback: () => void ): void;
42+
all(path: string, callback: Function): void;
43+
all(path: string, callback: Function, callback2: Function): void;
44+
locals: any;
45+
render(view: string, callback: (err: Error, html) => void ): void;
46+
render(view: string, opts: any, callback: (err: Error, html) => void ): void;
47+
routes: any;
48+
listen(port: number, hostname: string, backlog: number, callback: Function): void;
49+
listen(port: number, callback: Function): void;
50+
listen(path: string, callback?: Function): void;
51+
listen(handle: any, listeningListener?: Function): void;
52+
use(route: string, callback: Function): ExpressServer;
53+
use(route: string, server: ExpressServer): ExpressServer;
54+
use(callback: Function): ExpressServer;
55+
use(server: ExpressServer): ExpressServer;
56+
}
57+
58+
export interface ExpressServerRequest extends http.ServerRequest {
59+
params: any;
60+
query: any;
61+
body: any;
62+
files: any;
63+
param(name: string): any;
64+
route: any;
65+
cookies: any;
66+
signedCookies: any;
67+
get(field: string): string;
68+
accepts(types: string): any;
69+
accepts(types: string[]): any;
70+
accepted: any;
71+
is(type: string): bool;
72+
ip: string;
73+
ips: string[];
74+
path: string;
75+
host: string;
76+
fresh: bool;
77+
stale: bool;
78+
xhr: bool;
79+
protocol: string;
80+
secure: bool;
81+
subdomains: string[];
82+
acceptedLanguages: string[];
83+
acceptedCharsets: string[];
84+
acceptsCharset(charset: string): bool;
85+
acceptsLanguage(lang: string): bool;
86+
}
87+
88+
export interface ExpressServerResponse extends http.ServerResponse {
89+
status(code: number): any;
90+
set(field: any): void;
91+
set(field: string, value: string): void;
92+
header(field: any): void;
93+
header(field: string, value: string): void;
94+
get(field: string): any;
95+
cookie(name: string, value: any, options?: any): void;
96+
clearcookie(name: string, options?: any): void;
97+
redirect(status: number, url: string): void;
98+
redirect(url: string): void;
99+
charset: string;
100+
send(bodyOrStatus: any);
101+
send(body: any, status: any);
102+
send(body: any, headers: any, status: number);
103+
json(bodyOrStatus: any);
104+
json(body: any, status: any);
105+
json(body: any, headers: any, status: number);
106+
jsonp(bodyOrStatus: any);
107+
jsonp(body: any, status: any);
108+
jsonp(body: any, headers: any, status: number);
109+
type(type: string): void;
110+
format(object: any): void;
111+
attachment(filename?: string);
112+
sendfile(path: string): void;
113+
sendfile(path: string, options: any): void;
114+
sendfile(path: string, options: any, fn: (err: Error) =>void ): void;
115+
download(path: string): void;
116+
download(path: string, filename: string): void;
117+
download(path: string, filename: string, fn: (err: Error) =>void ): void;
118+
links(links: any): void;
119+
locals: any;
120+
render(view: string, locals: any): void;
121+
render(view: string, callback: (err: Error, html: any) =>void ): void;
122+
render(view: string, locals: any, callback: (err: Error, html: any) =>void ): void;
123+
}
124+
}

mongodb.d.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
///<reference path='..\node\node.d.ts' />
2+
3+
declare module "mongodb" {
4+
export class Server {
5+
constructor(host: string, port: number, opts?: any, moreopts?: any);
6+
}
7+
export class Db {
8+
constructor(databaseName: string, serverConfig: Server);
9+
public open(callback: ()=>void);
10+
public collection(name: string, callback: (err: any, collection: MongoCollection) => void);
11+
}
12+
export class ObjectID {
13+
constructor(s: string);
14+
}
15+
}
16+
17+
18+
interface MongoDb {
19+
20+
}
21+
22+
interface MongoCollection {
23+
find(query: any): MongoCursor;
24+
find(query: any, callback?: (err: any, result: any) => void): MongoCursor;
25+
find(query: any, select: any, callback?: (err: any, result: any) => void): MongoCursor;
26+
findOne(query: any, callback: (err: any, result: any) => void): void;
27+
update(query: any, updates: any, callback: (err: any, result: any) => void): void;
28+
insert(query: any, callback: (err: any, result: any) => void): void;
29+
}
30+
31+
interface MongoCursor {
32+
toArray(callback: (err: any, results: any[]) => void);
33+
}

0 commit comments

Comments
 (0)