import { TypeKind } from 'brisk-ts-extends'; import { Context, Request, Response } from 'koa'; import { BriskControllerSwaggerTag } from './swagger'; import { BriskIoCContext } from 'brisk-ioc'; export interface BriskControllerOption { cors?: boolean; globalBaseUrl?: string; staticPath?: string; swagger?: boolean; } export declare enum BRISK_CONTROLLER_ROUTER_TYPE_E { INTERCEPTOR = "0", REQUEST = "1" } export declare type BriskControllerRouterHandler = (ctx: Context) => any; export interface BriskControllerRouterOption { type?: BRISK_CONTROLLER_ROUTER_TYPE_E; method?: BRISK_CONTROLLER_METHOD_E | BRISK_CONTROLLER_METHOD_E[]; } export interface BriskControllerHeaders { [key: string]: string; } export interface BriskControllerPathInfo { path: string; params?: any; methodMap?: Map>; } export declare type BriskControllerRequestHandler = (...params: any[]) => any; export declare type BriskControllerInterceptorHandler = (req: Request, res: Response) => boolean | void; export interface BriskControllerValidatorResult { defaultTip: string; [key: string | number]: any; } export declare type BriskControllerValidator = (value: any) => { [key: string]: BriskControllerValidatorResult | null; } | null; export declare enum BRISK_CONTROLLER_METHOD_E { GET = "get", POST = "post", PUT = "put", DELETE = "delete" } export declare enum BRISK_CONTROLLER_PARAMETER_IS_E { IN_BODY = "inBody", BODY = "body", FORM_DATA = "formData", QUERY = "query", HEADER = "header", PATH = "path", FILE = "file", COOKIE = "cookie", NULL = "null", STATE = "state", CONTEXT = "context" } export interface BriskControllerParameter { name: string; is: BRISK_CONTROLLER_PARAMETER_IS_E; type: TypeKind; description?: string; required?: boolean; default?: any; validator?: BriskControllerValidator; } export interface BriskControllerInterceptorOption { method?: BRISK_CONTROLLER_METHOD_E | BRISK_CONTROLLER_METHOD_E[]; baseUrl?: string; } export interface BriskControllerRedirectInfo { urls: string[]; status?: number; } export interface BriskControllerRequestOption extends BriskControllerInterceptorOption { name?: string; title?: string; description?: string; params?: BriskControllerParameter[]; tag?: BriskControllerSwaggerTag; successResponseType?: TypeKind; redirect?: BriskControllerRedirectInfo; } export interface BriskControllerRedirect { _briskControllerRedirect: { targetPath: string; status: number; }; } export interface BriskControllerCookieOption { /** * a number representing the milliseconds from Date.now() for expiry */ maxAge?: number | undefined; /** * a Date object indicating the cookie's expiration * date (expires at the end of session by default). */ expires?: Date | undefined; /** * a string indicating the path of the cookie (/ by default). */ path?: string | undefined; /** * a string indicating the domain of the cookie (no default). */ domain?: string | undefined; /** * a boolean indicating whether the cookie is only to be sent * over HTTPS (false by default for HTTP, true by default for HTTPS). */ secure?: boolean | undefined; /** * "secureProxy" option is deprecated; use "secure" option, provide "secure" to constructor if needed */ secureProxy?: boolean | undefined; /** * a boolean indicating whether the cookie is only to be sent over HTTP(S), * and not made available to client JavaScript (true by default). */ httpOnly?: boolean | undefined; /** * a boolean or string indicating whether the cookie is a "same site" cookie (false by default). * This can be set to 'strict', 'lax', or true (which maps to 'strict'). */ sameSite?: 'strict' | 'lax' | 'none' | boolean | undefined; /** * a boolean indicating whether the cookie is to be signed (false by default). * If this is true, another cookie of the same name with the .sig suffix * appended will also be sent, with a 27-byte url-safe base64 SHA1 value * representing the hash of cookie-name=cookie-value against the first Keygrip key. * This signature key is used to detect tampering the next time a cookie is received. */ signed?: boolean | undefined; /** * a boolean indicating whether to overwrite previously set * cookies of the same name (false by default). If this is true, * all cookies set during the same request with the same * name (regardless of path or domain) are filtered out of * the Set-Cookie header when setting this cookie. */ overwrite?: boolean | undefined; } export declare class BriskControllerFileArray extends Array { } export interface BriskControllerFile { size: number; filepath: string; originalFilename?: string; newFilename: string; mimetype?: string; mtime?: Date | null | undefined; hashAlgorithm?: false | 'sha1' | 'md5' | 'sha256'; hash?: string | null; toString(): string; } export interface BriskControllerResultFactory { setCookie(key: string, value: string, option?: BriskControllerCookieOption): BriskControllerResultFactory; setHeader(key: string, value: string): BriskControllerResultFactory; toResult(): T; } export interface BriskControllerContext extends BriskIoCContext { state: any; }