From 5069d22d336cffd697ddf6bc6ca59c144d22e259 Mon Sep 17 00:00:00 2001 From: James Hulse Date: Wed, 4 Oct 2017 18:59:28 +0100 Subject: [PATCH] @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 --- types/connect-mongo/connect-mongo-tests.ts | 8 ++++++++ types/connect-mongo/index.d.ts | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/types/connect-mongo/connect-mongo-tests.ts b/types/connect-mongo/connect-mongo-tests.ts index a512d7dc71..67caed7c27 100644 --- a/types/connect-mongo/connect-mongo-tests.ts +++ b/types/connect-mongo/connect-mongo-tests.ts @@ -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}) +})); diff --git a/types/connect-mongo/index.d.ts b/types/connect-mongo/index.d.ts index 0b7443f7e1..6f71906fa5 100644 --- a/types/connect-mongo/index.d.ts +++ b/types/connect-mongo/index.d.ts @@ -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; + } + 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 {