Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 8bd1c18

Browse files
Updated typings.
1 parent df76897 commit 8bd1c18

File tree

6 files changed

+1154
-198
lines changed

6 files changed

+1154
-198
lines changed

imageboard/typings/express/express.d.ts

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
/* =================== USAGE ===================
77
8-
import express = require('express');
8+
import * as express from "express";
99
var app = express();
1010
1111
=============================================== */
1212

1313
/// <reference path="../node/node.d.ts" />
14+
/// <reference path="../serve-static/serve-static.d.ts" />
1415

1516
declare module Express {
1617

@@ -23,7 +24,8 @@ declare module Express {
2324

2425

2526
declare module "express" {
26-
import http = require('http');
27+
import * as http from "http";
28+
import * as serveStatic from "serve-static";
2729

2830
function e(): e.Express;
2931

@@ -38,6 +40,7 @@ declare module "express" {
3840
delete(...handler: RequestHandler[]): IRoute;
3941
patch(...handler: RequestHandler[]): IRoute;
4042
options(...handler: RequestHandler[]): IRoute;
43+
head(...handler: RequestHandler[]): IRoute;
4144
}
4245

4346
interface IRouterMatcher<T> {
@@ -95,13 +98,19 @@ declare module "express" {
9598
delete: IRouterMatcher<T>;
9699
patch: IRouterMatcher<T>;
97100
options: IRouterMatcher<T>;
101+
head: IRouterMatcher<T>;
98102

99103
route(path: string): IRoute;
100104

101105
use(...handler: RequestHandler[]): T;
102106
use(handler: ErrorRequestHandler): T;
103107
use(path: string, ...handler: RequestHandler[]): T;
104108
use(path: string, handler: ErrorRequestHandler): T;
109+
use(path: string[], ...handler: RequestHandler[]): T;
110+
use(path: string[], handler: ErrorRequestHandler): T;
111+
use(path: RegExp, ...handler: RequestHandler[]): T;
112+
use(path: RegExp, handler: ErrorRequestHandler): T;
113+
use(path:string, router:Router): T;
105114
}
106115

107116
export function Router(options?: any): Router;
@@ -349,6 +358,11 @@ declare module "express" {
349358
/**
350359
* Parse the "Host" header field hostname.
351360
*/
361+
hostname: string;
362+
363+
/**
364+
* @deprecated Use hostname instead.
365+
*/
352366
host: string;
353367

354368
/**
@@ -384,8 +398,6 @@ declare module "express" {
384398

385399
authenticatedUser: any;
386400

387-
files: any;
388-
389401
/**
390402
* Clear cookie `name`.
391403
*
@@ -403,6 +415,10 @@ declare module "express" {
403415
originalUrl: string;
404416

405417
url: string;
418+
419+
baseUrl: string;
420+
421+
app: Application;
406422
}
407423

408424
interface MediaType {
@@ -424,22 +440,22 @@ declare module "express" {
424440
* @param code
425441
*/
426442
status(code: number): Response;
427-
443+
428444
/**
429445
* Set the response HTTP status code to `statusCode` and send its string representation as the response body.
430446
* @link http://expressjs.com/4x/api.html#res.sendStatus
431-
*
447+
*
432448
* Examples:
433-
*
449+
*
434450
* res.sendStatus(200); // equivalent to res.status(200).send('OK')
435451
* res.sendStatus(403); // equivalent to res.status(403).send('Forbidden')
436452
* res.sendStatus(404); // equivalent to res.status(404).send('Not Found')
437453
* res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error')
438-
*
454+
*
439455
* @param code
440456
*/
441457
sendStatus(code: number): Response;
442-
458+
443459
/**
444460
* Set Link header field with the given `links`.
445461
*
@@ -537,19 +553,19 @@ declare module "express" {
537553
sendFile(path: string, options: any, fn: Errback): void;
538554

539555
/**
540-
* deprecated, use sendFile instead.
556+
* @deprecated Use sendFile instead.
541557
*/
542558
sendfile(path: string): void;
543559
/**
544-
* deprecated, use sendFile instead.
560+
* @deprecated Use sendFile instead.
545561
*/
546562
sendfile(path: string, options: any): void;
547563
/**
548-
* deprecated, use sendFile instead.
564+
* @deprecated Use sendFile instead.
549565
*/
550566
sendfile(path: string, fn: Errback): void;
551567
/**
552-
* deprecated, use sendFile instead.
568+
* @deprecated Use sendFile instead.
553569
*/
554570
sendfile(path: string, options: any, fn: Errback): void;
555571

@@ -796,7 +812,7 @@ declare module "express" {
796812
(req: Request, res: Response, next: Function): any;
797813
}
798814

799-
interface Handler extends RequestHandler {}
815+
interface Handler extends RequestHandler {}
800816

801817
interface RequestParamHandler {
802818
(req: Request, res: Response, next: Function, param: any): any;
@@ -1062,31 +1078,7 @@ declare module "express" {
10621078
response: Response;
10631079
}
10641080

1065-
/**
1066-
* Static:
1067-
*
1068-
* Static file server with the given `root` path.
1069-
*
1070-
* Examples:
1071-
*
1072-
* var oneDay = 86400000;
1073-
*
1074-
* connect()
1075-
* .use(connect.static(__dirname + '/public'))
1076-
*
1077-
* connect()
1078-
* .use(connect.static(__dirname + '/public', { maxAge: oneDay }))
1079-
*
1080-
* Options:
1081-
*
1082-
* - `maxAge` Browser cache maxAge in milliseconds. defaults to 0
1083-
* - `hidden` Allow transfer of hidden files. defaults to false
1084-
* - `redirect` Redirect to trailing "/" when the pathname is a dir. defaults to true
1085-
*
1086-
* @param root
1087-
* @param options
1088-
*/
1089-
function static(root: string, options?: any): RequestHandler;
1081+
var static: typeof serveStatic;
10901082
}
10911083

10921084
export = e;

imageboard/typings/mime/mime.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Type definitions for mime
2+
// Project: https://github.com/broofa/node-mime
3+
// Definitions by: Jeff Goddard <https://github.com/jedigo>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
// Imported from: https://github.com/soywiz/typescript-node-definitions/mime.d.ts
7+
8+
declare module "mime" {
9+
export function lookup(path: string): string;
10+
export function extension(mime: string): string;
11+
export function load(filepath: string): void;
12+
export function define(mimes: Object): void;
13+
14+
interface Charsets {
15+
lookup(mime: string): string;
16+
}
17+
18+
export var charsets: Charsets;
19+
}

imageboard/typings/mongodb/mongodb.d.ts

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ declare module "mongodb" {
127127
// Creates an ObjectID from a hex string representation of an ObjectID.
128128
// hexString – create a ObjectID from a passed in 24 byte hexstring.
129129
public static createFromHexString(hexString: string): ObjectID;
130+
131+
// Checks if a value is a valid bson ObjectId
132+
// id - Value to be checked
133+
public static isValid(id: string): Boolean;
134+
135+
// Generate a 12 byte id string used in ObjectID's
136+
// time - optional parameter allowing to pass in a second based timestamp
137+
public generate(time?: number): string;
130138
}
131139

132140
// Class documentation : http://mongodb.github.io/node-mongodb-native/api-bson-generated/binary.html
@@ -253,24 +261,97 @@ declare module "mongodb" {
253261
pkFactory?: PKFactory;
254262
}
255263

264+
// Documentation: http://docs.mongodb.org/manual/reference/command/collStats/
265+
export interface CollStats {
266+
// Namespace.
267+
ns: string;
268+
269+
// Number of documents.
270+
count: number;
271+
272+
// Collection size in bytes.
273+
size: number;
274+
275+
// Average object size in bytes.
276+
avgObjSize: number;
277+
278+
// (Pre)allocated space for the collection in bytes.
279+
storageSize: number;
280+
281+
// Number of extents (contiguously allocated chunks of datafile space).
282+
numExtents: number;
283+
284+
// Number of indexes.
285+
nindexes: number;
286+
287+
// Size of the most recently created extent in bytes.
288+
lastExtentSize: number;
289+
290+
// Padding can speed up updates if documents grow.
291+
paddingFactor: number;
292+
flags: number;
293+
294+
// Total index size in bytes.
295+
totalIndexSize: number;
296+
297+
// Size of specific indexes in bytes.
298+
indexSizes: {
299+
_id_: number;
300+
username: number;
301+
};
302+
}
303+
256304
// Documentation : http://mongodb.github.io/node-mongodb-native/api-generated/collection.html
257305
export interface Collection {
258306
new (db: Db, collectionName: string, pkFactory?: Object, options?: CollectionCreateOptions): Collection; // is this right?
259-
307+
/**
308+
* @deprecated use insertOne or insertMany
309+
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insert
310+
*/
260311
insert(query: any, callback: (err: Error, result: any) => void): void;
261312
insert(query: any, options: { safe?: any; continueOnError?: boolean; keepGoing?: boolean; serializeFunctions?: boolean; }, callback: (err: Error, result: any) => void): void;
262313

314+
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insertOne
315+
insertOne(doc:any, callback: (err: Error, result: any) => void) :void;
316+
insertOne(doc: any, options: { w?: any; wtimeout?: number; j?: boolean; serializeFunctions?: boolean; forceServerObjectId?: boolean }, callback: (err: Error, result: any) => void): void;
317+
318+
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insertMany
319+
insertMany(docs: any, callback: (err: Error, result: any) => void): void;
320+
insertMany(docs: any, options: { w?: any; wtimeout?: number; j?: boolean; serializeFunctions?: boolean; forceServerObjectId?: boolean }, callback: (err: Error, result: any) => void): void;
321+
/**
322+
* @deprecated use deleteOne or deleteMany
323+
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#remove
324+
*/
263325
remove(selector: Object, callback?: (err: Error, result: any) => void): void;
264326
remove(selector: Object, options: { safe?: any; single?: boolean; }, callback?: (err: Error, result: any) => void): void;
265327

328+
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#deleteOne
329+
deleteOne(filter: any, callback: (err: Error, result: any) => void): void;
330+
deleteOne(filter: any, options: { w?: any; wtimeout?: number; j?: boolean;}, callback: (err: Error, result: any) => void): void;
331+
332+
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#deleteMany
333+
deleteMany(filter: any, callback: (err: Error, result: any) => void): void;
334+
deleteMany(filter: any, options: { w?: any; wtimeout?: number; j?: boolean;}, callback: (err: Error, result: any) => void): void;
335+
266336
rename(newName: String, callback?: (err: Error, result: any) => void): void;
267337

268338
save(doc: any, callback : (err: Error, result: any) => void): void;
269-
save(doc: any, options: { safe: any; }, callback : (err: Error, result: any) => void): void;
270-
339+
save(doc: any, options: { w?: any; wtimeout?: number; j?: boolean;}, callback : (err: Error, result: any) => void): void;
340+
/**
341+
* @deprecated use updateOne or updateMany
342+
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#update
343+
*/
271344
update(selector: Object, document: any, callback?: (err: Error, result: any) => void): void;
272345
update(selector: Object, document: any, options: { safe?: boolean; upsert?: any; multi?: boolean; serializeFunctions?: boolean; }, callback: (err: Error, result: any) => void): void;
273346

347+
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#updateOne
348+
updateOne(filter: Object, update: any, callback: (err: Error, result: any) => void): void;
349+
updateOne(filter: Object, update: any, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean;}, callback: (err: Error, result: any) => void): void;
350+
351+
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#updateMany
352+
updateMany(filter: Object, update: any, callback: (err: Error, result: any) => void): void;
353+
updateMany(filter: Object, update: any, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean;}, callback: (err: Error, result: any) => void): void;
354+
274355
distinct(key: string, query: Object, callback: (err: Error, result: any) => void): void;
275356
distinct(key: string, query: Object, options: { readPreference: string; }, callback: (err: Error, result: any) => void): void;
276357

@@ -279,13 +360,31 @@ declare module "mongodb" {
279360
count(query: Object, options: { readPreference: string; }, callback: (err: Error, result: any) => void): void;
280361

281362
drop(callback?: (err: Error, result: any) => void): void;
282-
363+
/**
364+
* @deprecated use findOneAndUpdate, findOneAndReplace or findOneAndDelete
365+
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify
366+
*/
283367
findAndModify(query: Object, sort: any[], doc: Object, callback: (err: Error, result: any) => void): void;
284368
findAndModify(query: Object, sort: any[], doc: Object, options: { safe?: any; remove?: boolean; upsert?: boolean; new?: boolean; }, callback: (err: Error, result: any) => void): void;
285-
369+
/**
370+
* @deprecated use findOneAndDelete
371+
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndRemove
372+
*/
286373
findAndRemove(query : Object, sort? : any[], callback?: (err: Error, result: any) => void): void;
287374
findAndRemove(query : Object, sort? : any[], options?: { safe: any; }, callback?: (err: Error, result: any) => void): void;
288375

376+
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findOneAndDelete
377+
findOneAndDelete(filter: any, callback: (err: Error, result: any) => void): void;
378+
findOneAndDelete(filter: any, options: { projection?: any; sort?: any; maxTimeMS?: number; }, callback: (err: Error, result: any) => void): void;
379+
380+
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findOneAndReplace
381+
findOneAndReplace(filter: any, replacement: any, callback: (err: Error, result: any) => void): void;
382+
findOneAndReplace(filter: any, replacement: any, options: { projection?: any; sort?: any; maxTimeMS?: number; upsert?: boolean; returnOriginal?: boolean }, callback: (err: Error, result: any) => void): void;
383+
384+
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findOneAndUpdate
385+
findOneAndUpdate(filter: any, update: any, callback: (err: Error, result: any) => void): void;
386+
findOneAndUpdate(filter: any, update: any, options: { projection?: any; sort?: any; maxTimeMS?: number; upsert?: boolean; returnOriginal?: boolean }, callback: (err: Error, result: any) => void): void;
387+
289388
find(callback?: (err: Error, result: Cursor) => void): Cursor;
290389
find(selector: Object, callback?: (err: Error, result: Cursor) => void): Cursor;
291390
find(selector: Object, fields: any, callback?: (err: Error, result: Cursor) => void): Cursor;
@@ -326,8 +425,8 @@ declare module "mongodb" {
326425
indexes(callback: Function): void;
327426
aggregate(pipeline: any[], callback: (err: Error, results: any) => void): void;
328427
aggregate(pipeline: any[], options: {readPreference: string}, callback: (err: Error, results: any) => void): void;
329-
stats(options: {readPreference: string; scale: number}, callback: Function): void;
330-
stats(callback: (err: Error, results: any) => void): void;
428+
stats(options: {readPreference: string; scale: number}, callback: (err: Error, results: CollStats) => void): void;
429+
stats(callback: (err: Error, results: CollStats) => void): void;
331430

332431
hint: any;
333432
}
@@ -436,6 +535,7 @@ declare module "mongodb" {
436535
export interface MongoCollectionOptions {
437536
safe?: any;
438537
serializeFunctions?: any;
538+
strict?: boolean;
439539
raw?: boolean;
440540
pkFactory?: any;
441541
readPreference?: string;

0 commit comments

Comments
 (0)