/// import { IncomingMessage } from 'http'; import { RequestMethod, Route } from '@red5/router'; import { Response } from '.'; import { Session } from '@red5/session'; export interface FileType { /** * The name of the form field * * @type {string} * @memberof FileType */ key: string; /** * The original name of the uploaded file `example.jpg` * * @type {string} * @memberof FileType */ filename: string; /** * The full location of the tmp file `/tmp/dir/red5/uploads/xxxyyyzzz.tmp` * * @type {string} * @memberof FileType */ tmpFilePath: string; /** * The name of the tmp file `xxxyyyzzz.tmp` * * @type {string} * @memberof FileType */ tmpFilename: string; /** * The location of the tmp file relative to the storage disk's root `/red5/uploads/xxxyyyzzz.tmp` * * @type {string} * @memberof FileType */ tmpStoragePath: string; } export declare type Lang = { [key: string]: any; }; export declare type Helpers = { [key: string]: Function; }; export declare class Client { readonly method: RequestMethod; readonly ajax: boolean; private _post; private readonly _get; private readonly _files; private readonly _headers; private readonly _response; private readonly _id; private _req; route: Route; session?: Session; readonly request: IncomingMessage; constructor(req: IncomingMessage); /** * Initialize anything that shouldn't be initialized in the constructor * * @memberof Client */ init(): Promise; /** * Attempts to read the information about the body of the request, such as attachments * * @param {string} body The received body string from the request * @memberof Client */ setBody(body: string): Promise; /** * Gets the path from the route, if it isn't found return `/` as the path * * @readonly * @type {string} * @memberof Client */ readonly path: string; readonly response: Response; /** * Gets data from a request * * @readonly * @memberof Client */ readonly data: { /** * Gets all of the items in the query string */ readonly getAll: object; /** * Gets all of the items in the post data */ readonly postAll: object; readonly requestAll: object; /** * Gets the file information from a request * * @param {string} key The key that was used to reference the file * @returns */ files(key: string): FileType | undefined; /** * Gets a query parameter and if it is not found return the default value * * @template T * @param {string} key The key to the query parameter * @param {*} [defaultValue=''] The default value if the key doesn't exist * @returns {T} */ get(key: string, defaultValue?: any): T; /** * Gets a post parameter * * @template T * @param {string} key The key to the post parameter * @param {*} [defaultValue=''] The default value if the key doesn't exist * @returns {T} */ post(key: string, defaultValue?: any): T; /** * Gets a parameter no matter if it is a `post` or `get` parameter. * If the key is in both the `get` and `post` data, the `get` key will be returned * * @template T * @param {string} key The key to the get or post parameter * @param {*} [defaultValue=''] The default value if the key doesn't exist * @returns {T} */ request(key: string, defaultValue?: any): T; /** * Gets the request data and converts it to an object * * @returns */ toObject(): Readonly<{ get: { [key: string]: any; }; post: { [key: string]: any; }; files: { [key: string]: FileType; }; }>; }; /** * Reads the headers * * @readonly * @memberof Client */ readonly headers: { /** * Gets a item from the headers * * @template T * @param {string} key The header key * @param {*} [defaultValue=''] The default value if the key doesn't exist * @returns {T} */ get(key: string, defaultValue?: any): T; /** * Checks if a header is set * * @param {string} key The header key * @returns */ has(key: string): boolean; /** * Checks if a header is set with an exact value * * @param {string} key The header key * @param {*} value The value that the headers value MUST equal * @returns */ is(key: string, value: any): boolean; /** * All of the header values * * @returns */ all(): any; }; /** * Gets the request's unique identifer which is created upon request * * @readonly * @type {string} * @memberof Client */ readonly id: string; setRoute(route: Route): this; setLocale(locale: string): this; getLocale(): string; trans(key: string, data?: { [key: string]: any; }): Promise; }