|
1 |
| -import session, { Store } from "express-session"; |
| 1 | +import * as express from "express"; |
| 2 | +import * as session from "express-session"; |
2 | 3 | import {
|
3 | 4 | DynamoDBClient,
|
4 | 5 | GetItemCommandOutput,
|
5 | 6 | ProvisionedThroughput,
|
6 | 7 | ScalarAttributeType,
|
7 | 8 | } from "@aws-sdk/client-dynamodb";
|
8 | 9 |
|
| 10 | +export = ConnectDynamoDB; |
| 11 | + |
9 | 12 | declare function ConnectDynamoDB<Session extends Record<string, unknown>>(
|
10 |
| - connect: typeof session |
11 |
| -): DynamoDBStore<Session>; |
12 |
| -export default ConnectDynamoDB; |
| 13 | + connect: (options?: session.SessionOptions) => express.RequestHandler |
| 14 | +): ConnectDynamoDB.DynamoDBStore<Session>; |
13 | 15 |
|
14 |
| -export interface DynamoDBStoreOptions { |
15 |
| - /** A preconfigured client. If not supplied standard SDK environmental variables will be used. */ |
16 |
| - client?: DynamoDBClient; |
17 |
| - /** Defaults to 'sessions' */ |
18 |
| - table?: string; |
19 |
| - /** Defaults to 'sess:' */ |
20 |
| - prefix?: string; |
21 |
| - /** Defaults to 'id' */ |
22 |
| - hashKey?: string; |
23 |
| - readCapacityUnits?: ProvisionedThroughput["ReadCapacityUnits"]; |
24 |
| - writeCapacityUnits?: ProvisionedThroughput["WriteCapacityUnits"]; |
25 |
| - specialKeys?: DynamoDBStoreOptionsSpecialKey[]; |
26 |
| - skipThrowMissingSpecialKeys?: boolean; |
27 |
| - /** |
28 |
| - * @deprecated |
29 |
| - * Upgrade to DynamoDB's TimeToLive configuration. |
30 |
| - */ |
31 |
| - reapInterval?: number; |
32 |
| -} |
| 16 | +declare namespace ConnectDynamoDB { |
| 17 | + interface DynamoDBStoreOptions { |
| 18 | + /** A preconfigured client. If not supplied standard SDK environmental variables will be used. */ |
| 19 | + client?: DynamoDBClient; |
| 20 | + /** Defaults to 'sessions' */ |
| 21 | + table?: string; |
| 22 | + /** Defaults to 'sess:' */ |
| 23 | + prefix?: string; |
| 24 | + /** Defaults to 'id' */ |
| 25 | + hashKey?: string; |
| 26 | + readCapacityUnits?: ProvisionedThroughput["ReadCapacityUnits"]; |
| 27 | + writeCapacityUnits?: ProvisionedThroughput["WriteCapacityUnits"]; |
| 28 | + specialKeys?: DynamoDBStoreOptionsSpecialKey[]; |
| 29 | + skipThrowMissingSpecialKeys?: boolean; |
| 30 | + /** |
| 31 | + * @deprecated |
| 32 | + * Upgrade to DynamoDB's TimeToLive configuration. |
| 33 | + */ |
| 34 | + reapInterval?: number; |
| 35 | + } |
33 | 36 |
|
34 |
| -interface DynamoDBStoreOptionsSpecialKey { |
35 |
| - name: string; // The session key |
36 |
| - type: ScalarAttributeType | "B" | "N" | "S"; |
37 |
| -} |
| 37 | + interface DynamoDBStoreOptionsSpecialKey { |
| 38 | + name: string; // The session key |
| 39 | + type: ScalarAttributeType | "B" | "N" | "S"; |
| 40 | + } |
38 | 41 |
|
39 |
| -export type DynamoDBStore< |
40 |
| - Session extends Record<string, unknown> = Record<string, unknown> |
41 |
| -> = Store & { |
42 |
| - readonly client: DynamoDBClient; |
43 |
| - new (options?: DynamoDBStoreOptions): DynamoDBStore<Session>; |
44 |
| - initialize(): Promise<void>; |
45 |
| - describeSessionsTable(): Promise<void>; |
46 |
| - createSessionsTable(): Promise<void>; |
47 |
| - get( |
48 |
| - id: string, |
49 |
| - callback: (err: CallbackError, session?: Session | null) => void |
50 |
| - ): void; |
51 |
| - getParsedSession( |
52 |
| - output: Pick<GetItemCommandOutput, "Item"> |
53 |
| - ): Record<string, unknown>; |
54 |
| - set(id: string, callback: (err: CallbackError) => void): void; |
55 |
| - reap(callback?: (err: CallbackError) => void): void; |
56 |
| - destroy(id: string, callback?: (err: CallbackError) => void): void; |
57 |
| - getExpiresValue(): number; |
58 |
| - touch( |
59 |
| - id: string, |
60 |
| - callback?: (err: CallbackError, results: { expires: number }) => void |
61 |
| - ): void; |
62 |
| - clearInterval(): void; |
63 |
| -}; |
| 42 | + type DynamoDBStore< |
| 43 | + Session extends Record<string, unknown> = Record<string, unknown> |
| 44 | + > = session.Store & { |
| 45 | + readonly client: DynamoDBClient; |
| 46 | + new (options?: DynamoDBStoreOptions): DynamoDBStore<Session>; |
| 47 | + initialize(): Promise<void>; |
| 48 | + describeSessionsTable(): Promise<void>; |
| 49 | + createSessionsTable(): Promise<void>; |
| 50 | + get( |
| 51 | + id: string, |
| 52 | + callback: (err: CallbackError, session?: Session | null) => void |
| 53 | + ): void; |
| 54 | + getParsedSession( |
| 55 | + output: Pick<GetItemCommandOutput, "Item"> |
| 56 | + ): Record<string, unknown>; |
| 57 | + set(id: string, callback: (err: CallbackError) => void): void; |
| 58 | + reap(callback?: (err: CallbackError) => void): void; |
| 59 | + destroy(id: string, callback?: (err: CallbackError) => void): void; |
| 60 | + getExpiresValue(): number; |
| 61 | + touch( |
| 62 | + id: string, |
| 63 | + callback?: (err: CallbackError, results: { expires: number }) => void |
| 64 | + ): void; |
| 65 | + clearInterval(): void; |
| 66 | + }; |
64 | 67 |
|
65 |
| -type CallbackError = Error | undefined | null; |
| 68 | + type CallbackError = Error | undefined | null; |
| 69 | +} |
0 commit comments