UNPKG

@tdb/util

Version:
34 lines (33 loc) 944 B
export declare type CookieValue = string | object; export interface ICookies { [key: string]: CookieValue; } export interface ICookieServerContext { req: { cookies: ICookies; }; res: { setHeader(key: string, value: string | number | string[]): void; }; } export interface ICookieOptions extends ICookieAttributes { ctx?: ICookieServerContext; default?: CookieValue; } export interface ICookieAttributes { expires?: number | Date; path?: string; domain?: string; isSecure?: boolean; } export declare type CookiePropertyFunc<T extends CookieValue> = (value?: T | null, options?: ICookieOptions) => T | undefined; export declare type CookieProperty<T extends CookieValue> = CookiePropertyFunc<T> & { key: string; isProp: boolean; options?: ICookieOptions; }; export interface ICookieChangedEvent { key: string; value?: CookieValue; action: 'UPDATE' | 'DELETE'; }