mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-21 21:31:12 +08:00
Added type declarations for 'documentdb-session'. (#19992)
This commit is contained in:
committed by
Mohamed Hegazy
parent
73dd199e0f
commit
f020f37da2
18
types/documentdb-session/documentdb-session-tests.ts
Normal file
18
types/documentdb-session/documentdb-session-tests.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import express = require("express");
|
||||
import session = require("express-session");
|
||||
import DocumentDBSession = require("documentdb-session");
|
||||
|
||||
const DocumentDBStore = DocumentDBSession(session);
|
||||
const store = new DocumentDBStore({
|
||||
database: "MY_DATABASE",
|
||||
collection: "MY_COLLECTION",
|
||||
host: "https://sample.documents.azure.com:443/",
|
||||
ttl: 60 * 60 * 10, // 10 hours
|
||||
key: "magic key"
|
||||
});
|
||||
|
||||
const app = express();
|
||||
session({
|
||||
store,
|
||||
secret: "I can count all the way to 55",
|
||||
});
|
||||
63
types/documentdb-session/index.d.ts
vendored
Normal file
63
types/documentdb-session/index.d.ts
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Type definitions for documentdb-session 1.0
|
||||
// Project: https://github.com/dwhieb/documentdb-session#readme
|
||||
// Definitions by: Daniel Rosenwasser <https://github.com/DanielRosenwasser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import session = require("express-session");
|
||||
|
||||
export = DocumentDBSession;
|
||||
|
||||
declare function DocumentDBSession(expressSession: typeof session): DocumentDBStoreConstructor;
|
||||
|
||||
interface DocumentDBStoreConstructor {
|
||||
new (options: Options): session.Store;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* The ID of the collection where the session data should be stored.
|
||||
* If the collection does not exist, it will be created when the session store initializes.
|
||||
* The collection may contain other data, or it may be a dedicated collection just for sessions.
|
||||
*
|
||||
* @default `"sessions"`
|
||||
*/
|
||||
collection?: string;
|
||||
|
||||
/**
|
||||
* The ID of the database where the session data should be stored.
|
||||
* If the database does not exist, it will be creaed when the session store initializes.
|
||||
*
|
||||
* @default `"sessionstore"`
|
||||
*/
|
||||
database?: string;
|
||||
|
||||
/**
|
||||
* By default, `documentdb-session` sets a `"type"` attribute on each session document with a value of `"session"`,
|
||||
* to distinguish session documents from other documents in the collection.
|
||||
* If you would like a different attribute or value to be used to discriminate session documents from other documents,
|
||||
* enter that as an attribute-value pair in an object here, e.g. `{ site: "mysite.com" }` or `{ _type: "session" }`.
|
||||
*
|
||||
* @default `{ type: "session" }`
|
||||
*/
|
||||
discriminator?: object;
|
||||
/**
|
||||
* The URL / hostname of your DocumentDB database account, usually of the form `https://mydbaccount.documents.azure.com:443/`.
|
||||
* You can also provide this in an environment variable, (`DOCUMENTDB_URL`) instead.
|
||||
*/
|
||||
host: string;
|
||||
/**
|
||||
* The primary key for your DocumentDB account.
|
||||
* A primary key is required because `documentdb-session` may create a new database for your account, if none exists.
|
||||
* You can also provide this in an environment variable (`DOCUMENTDB_KEY`) instead.
|
||||
*/
|
||||
key: string;
|
||||
/**
|
||||
* The TTL (time-to-live or expiration time) for your sessions, in seconds.
|
||||
* After this time has elapsed since the last change to the session data, the session will be deleted.
|
||||
* A session's TTL is extended each time session data is changed, restarting the timer.
|
||||
* See more on [**Configuring TTL**](https://github.com/dwhieb/documentdb-session#configuring-ttl-time-to-live-or-expiration-time).
|
||||
* *Enabling TTL is strongly recommended.*
|
||||
*/
|
||||
ttl?: number;
|
||||
}
|
||||
22
types/documentdb-session/tsconfig.json
Normal file
22
types/documentdb-session/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"documentdb-session-tests.ts"
|
||||
]
|
||||
}
|
||||
6
types/documentdb-session/tslint.json
Normal file
6
types/documentdb-session/tslint.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-irregular-whitespace": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user