@types/connect-mongo Add Promise constructor and fix spelling mistake (#20178)

* Added Promise constructor and fixed spelling mistake

* Fix spacing

* Merged types in constructor and added test
This commit is contained in:
James Hulse
2017-10-04 18:59:28 +01:00
committed by Ryan Cavanaugh
parent e07dba0a0e
commit 5069d22d33
2 changed files with 14 additions and 4 deletions

View File

@@ -43,3 +43,11 @@ app.use(session({
secret: 'secret',
store: new MongoStore({db: mongoDb})
}));
// NativeMongoPromiseOptions
var Client = mongodb.MongoClient;
var mongoDbPromise = Client.connect('mongodb://localhost/test');
app.use(session({
secret: 'secret',
store: new MongoStore({ dbPromise: mongoDbPromise})
}));

View File

@@ -91,14 +91,16 @@ declare namespace connectMongo {
mongooseConnection: mongoose.Connection;
}
export interface NaitiveMongoOptions extends DefaultOptions {
export interface NativeMongoOptions extends DefaultOptions {
db: mongodb.Db;
}
export interface NativeMongoPromiseOptions extends DefaultOptions {
dbPromise: Promise<mongodb.Db>;
}
export interface MongoStoreFactory {
new (options: MongoUrlOptions): MongoStore;
new (options: MogooseConnectionOptions): MongoStore;
new (options: NaitiveMongoOptions): MongoStore;
new(options: MongoUrlOptions | MogooseConnectionOptions | NativeMongoOptions | NativeMongoPromiseOptions): MongoStore;
}
export class MongoStore extends session.Store {