-
Notifications
You must be signed in to change notification settings - Fork 341
/
Copy pathtypes.d.ts
128 lines (103 loc) · 3.62 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Type definitions for connect-mongo 3.2.0
// Project: https://github.com/kcbanner/connect-mongo
// Definitions by: Mizuki Yamamoto <https://github.com/Syati>
// Guy Ellis <https://github.com/guyellis>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
/// <reference types="express-session" />
import * as express from 'express';
import * as mongoose from 'mongoose';
import * as mongodb from 'mongodb';
import * as session from 'express-session';
declare function connectMongo(connect: (options?: session.SessionOptions) => express.RequestHandler): connectMongo.MongoStoreFactory;
declare namespace connectMongo {
export interface DefaultOptions {
/**
* The hostname of the database you are connecting to.
* (Default: '127.0.0.1')
*/
host?: string;
/**
* The port number to connect to.
* (Default: 27017)
*/
port?: string;
/**
* (Default: false)
*/
autoReconnect?: boolean;
/**
* (Default: true)
*/
ssl?: boolean;
/**
* (Default: 1)
*/
w?: number;
/**
* The colletion of the database you are connecting to.
* (Default: sessions)
*/
collection?: string;
/**
* Serialize sessions using JSON.stringify and deserialize them with JSON.parse.
* (Default: true)
*/
stringify?: boolean;
/**
* Default: false
*/
hash?: boolean;
/**
* Default: 14 days (60 * 60 * 24 * 14)
*/
ttl?: number;
/**
* Automatically remove expired sessions.
* (Default: 'native')
*/
autoRemove?: string;
/**
* (Default: 10)
*/
autoRemoveInterval?: number;
/**
* don't save session if unmodified
*/
touchAfter?: number;
/**
* Enables transparent crypto in accordance with OWASP session management recommendations.
*/
secret?: string
/**
* A name of database used for storing sessions. Can be used with `url`, `client` or `clientPromise` options. Takes precedence over database name present in the connection string.
*/
dbName?: string
}
export interface MongoUrlOptions extends DefaultOptions {
url: string;
mongoOptions?: mongoose.ConnectionOptions;
}
export interface MongooseConnectionOptions extends DefaultOptions {
mongooseConnection: mongoose.Connection;
}
export interface NativeMongoOptions extends DefaultOptions {
client: mongodb.MongoClient;
}
export interface NativeMongoPromiseOptions extends DefaultOptions {
clientPromise: Promise<mongodb.MongoClient>;
}
export interface MongoStoreFactory {
new(options: MongoUrlOptions | MongooseConnectionOptions | NativeMongoOptions | NativeMongoPromiseOptions): MongoStore;
}
export class MongoStore extends session.Store {
get: (sid: string, callback: (err: any, session: Express.SessionData | null) => void) => void;
set: (sid: string, session: Express.SessionData, callback?: (err: any) => void) => void;
destroy: (sid: string, callback?: (err: any) => void) => void;
length: (callback: (err: any, length: number) => void) => void;
clear: (callback?: (err?: any) => void) => void;
touch: (sid: string, session: Express.SessionData, callback?: (err: any) => void) => void;
close: () => void;
}
}
export = connectMongo;