-
Notifications
You must be signed in to change notification settings - Fork 66
/
index.test-d.ts
53 lines (48 loc) · 1.41 KB
/
index.test-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
import { expectType } from "tsd";
import connectDynamoDB, {
DynamoDBStore,
DynamoDBStoreOptions,
DynamoDBStoreOptionsSpecialKey,
} from ".";
import expressSession from "express-session";
import express from "express";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
expectType<DynamoDBStore>(connectDynamoDB(expressSession));
expectType<connectDynamoDB.DynamoDBStore>(connectDynamoDB(expressSession));
type SessionData = {
name: string;
animal: "cow" | "pig";
};
const DynamoDBStore: DynamoDBStore =
connectDynamoDB<SessionData>(expressSession);
const specialKeysOption: DynamoDBStoreOptionsSpecialKey = {
name: "userId",
type: "S",
};
const specialKeysOptions: connectDynamoDB.DynamoDBStoreOptionsSpecialKey[] = [
specialKeysOption,
];
const options: DynamoDBStoreOptions = {
table: "myapp-sessions",
client: new DynamoDBClient({ endpoint: "http://localhost:8000" }),
readCapacityUnits: 25,
writeCapacityUnits: 25,
specialKeys: specialKeysOptions,
skipThrowMissingSpecialKeys: true,
initialized: true,
};
expectType<express.RequestHandler>(
expressSession({ store: new DynamoDBStore(), secret: "keyboard cat" })
);
expectType<express.RequestHandler>(
expressSession({
store: new DynamoDBStore({ table: "myapp-sessions" }),
secret: "keyboard cat",
})
);
expectType<express.RequestHandler>(
expressSession({
store: new DynamoDBStore(options),
secret: "keyboard cat",
})
);