1 | import { Context } from './context';
|
2 | import { MaybePromise } from './composer';
|
3 | import { MiddlewareFn } from './middleware';
|
4 | export interface SessionStore<T> {
|
5 | get: (name: string) => MaybePromise<T | undefined>;
|
6 | set: (name: string, value: T) => MaybePromise<void>;
|
7 | delete: (name: string) => MaybePromise<void>;
|
8 | }
|
9 | interface SessionOptions<S extends object> {
|
10 | getSessionKey?: (ctx: Context) => Promise<string | undefined>;
|
11 | store?: SessionStore<S>;
|
12 | }
|
13 | export interface SessionContext<S extends object> extends Context {
|
14 | session?: S;
|
15 | }
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | export declare function session<S extends object>(options?: SessionOptions<S>): MiddlewareFn<SessionContext<S>>;
|
32 |
|
33 | export declare class MemorySessionStore<T> implements SessionStore<T> {
|
34 | private readonly ttl;
|
35 | private readonly store;
|
36 | constructor(ttl?: number);
|
37 | get(name: string): T | undefined;
|
38 | set(name: string, value: T): void;
|
39 | delete(name: string): void;
|
40 | }
|
41 | export declare function isSessionContext<S extends object>(ctx: Context): ctx is SessionContext<S>;
|
42 | export {};
|
43 |
|
\ | No newline at end of file |