mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-24 13:59:25 +08:00
add sessionConfig interface
This commit is contained in:
105
types/koa-session/index.d.ts
vendored
105
types/koa-session/index.d.ts
vendored
@@ -15,59 +15,50 @@
|
||||
|
||||
import * as Koa from "koa";
|
||||
|
||||
declare function session(CONFIG: {
|
||||
/**
|
||||
* cookie key (default is koa:sess)
|
||||
*/
|
||||
key?: string,
|
||||
|
||||
/**
|
||||
* maxAge in ms (default is 1 days)
|
||||
* 'session' will result in a cookie that expires when session/browser is closed
|
||||
* Warning: If a session cookie is stolen, this cookie will never expire
|
||||
*/
|
||||
maxAge?: number | 'session',
|
||||
|
||||
/**
|
||||
* can overwrite or not (default true)
|
||||
*/
|
||||
overwrite?: boolean,
|
||||
|
||||
/**
|
||||
* httpOnly or not (default true)
|
||||
*/
|
||||
httpOnly?: boolean,
|
||||
|
||||
/**
|
||||
* signed or not (default true)
|
||||
*/
|
||||
signed?: boolean,
|
||||
|
||||
/**
|
||||
* You can store the session content in external stores(redis, mongodb or other DBs)
|
||||
*/
|
||||
store?: session.stores,
|
||||
|
||||
/**
|
||||
* Hook: valid session value before use it
|
||||
*/
|
||||
valid(...rest: any[]): void,
|
||||
|
||||
/**
|
||||
* Hook: before save session
|
||||
*/
|
||||
beforeSave(...rest: any[]): void,
|
||||
}, app: Koa): Koa.Middleware;
|
||||
|
||||
declare function session(app: Koa): Koa.Middleware;
|
||||
|
||||
declare module 'koa' {
|
||||
interface Context {
|
||||
session: session.sessionProps;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace session {
|
||||
interface sessionConfig {
|
||||
/**
|
||||
* cookie key (default is koa:sess)
|
||||
*/
|
||||
key?: string,
|
||||
|
||||
/**
|
||||
* maxAge in ms (default is 1 days)
|
||||
* 'session' will result in a cookie that expires when session/browser is closed
|
||||
* Warning: If a session cookie is stolen, this cookie will never expire
|
||||
*/
|
||||
maxAge?: number | 'session',
|
||||
|
||||
/**
|
||||
* can overwrite or not (default true)
|
||||
*/
|
||||
overwrite?: boolean,
|
||||
|
||||
/**
|
||||
* httpOnly or not (default true)
|
||||
*/
|
||||
httpOnly?: boolean,
|
||||
|
||||
/**
|
||||
* signed or not (default true)
|
||||
*/
|
||||
signed?: boolean,
|
||||
|
||||
/**
|
||||
* You can store the session content in external stores(redis, mongodb or other DBs)
|
||||
*/
|
||||
store?: session.stores,
|
||||
|
||||
/**
|
||||
* Hook: valid session value before use it
|
||||
*/
|
||||
valid(...rest: any[]): void,
|
||||
|
||||
/**
|
||||
* Hook: before save session
|
||||
*/
|
||||
beforeSave(...rest: any[]): void,
|
||||
}
|
||||
interface sessionProps {
|
||||
/**
|
||||
* Returns true if the session is new
|
||||
@@ -104,4 +95,14 @@ declare namespace session {
|
||||
}
|
||||
}
|
||||
|
||||
declare function session(CONFIG: session.sessionConfig, app: Koa): Koa.Middleware;
|
||||
|
||||
declare function session(app: Koa): Koa.Middleware;
|
||||
|
||||
declare module 'koa' {
|
||||
interface Context {
|
||||
session: session.sessionProps;
|
||||
}
|
||||
}
|
||||
|
||||
export = session;
|
||||
|
||||
Reference in New Issue
Block a user