add options.externalKey in koa-session (#42646)

This commit is contained in:
vvnab 2020-03-02 20:52:21 +03:00 committed by GitHub
parent a20e6d6ce7
commit b715241f21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,6 +155,12 @@ declare namespace session {
*/
store?: stores;
/**
* External key is used the cookie by default,
* but you can use options.externalKey to customize your own external key methods.
*/
externalKey?: ExternalKeys;
/**
* If your session store requires data or utilities from context, opts.ContextStore is alse supported.
* ContextStore must be a class which claims three instance methods demonstrated above.
@ -194,6 +200,18 @@ declare namespace session {
*/
destroy(key: string): any;
}
interface ExternalKeys {
/**
* get session object by key
*/
get(ctx: Koa.Context): string;
/**
* set session object for key, with a maxAge (in ms)
*/
set(ctx: Koa.Context, value: any): void;
}
}
declare function session(CONFIG: Partial<session.opts>, app: Koa): Koa.Middleware;