import { trans } from "@mongez/localization"; import { LogLevel } from "@mongez/logger"; import { FastifyRequest } from "fastify"; import type { Auth } from "../auth/models/auth"; import type { Middleware, Route } from "../router"; import { Validator } from "../validator/validator"; import { UploadedFile } from "./UploadedFile"; import { Response } from "./response"; import { RequestEvent } from "./types"; export declare class Request { /** * Fastify Request object */ baseRequest: FastifyRequest; /** * Response Object */ response: Response; /** * Route Object */ route: Route; /** * Parsed Request Payload */ protected payload: any; /** * Current user */ user: User; /** * Current request instance */ static current: Request; /** * Validator instance */ protected validator: Validator; /** * Translation method * Type of it is the same as the type of trans function */ trans: ReturnType; /** * Alias to trans method */ t: ReturnType; /** * Allow the request instance to accept dynamic properties */ [key: string]: any; /** * Set request handler */ setRequest(request: FastifyRequest): this; /** * Get current locale code */ get locale(): any; get localized(): any; /** * Get current locale code or return default locale code */ getLocaleCode(defaultLocaleCode?: string): any; /** * Get http protocol */ get protocol(): any; /** * Validate the given rules */ validate(rules: any): Promise; /** * Clear current user */ clearCurrentUser(): void; /** * Get value of the given header */ header(name: string, defaultValue?: any): any; /** * Get the current request domain */ get domain(): any; /** * Get hostname */ get hostname(): any; /** * Get request origin */ get origin(): string; /** * Get the domain of the origin */ get originDomain(): string; /** * Get authorization header value */ get authorizationValue(): any; /** * Get the authorization header */ get authorization(): any; /** * Get current request method */ get method(): any; /** * Parse the payload and merge it from the request body, params and query string */ protected parsePayload(): void; /** * Parse body payload */ protected parseBody(data: any): any; /** * Parse the given data */ protected parseInputValue(data: any): any; /** * Set route handler */ setRoute(route: Route): this; /** * Trigger an http event */ trigger(eventName: RequestEvent, ...args: any[]): any; /** * Listen to the given event */ on(eventName: RequestEvent, callback: any): any; /** * Make a log message */ log(message: any, level?: LogLevel): void; /** * Get current request path */ get path(): any; /** * {@alias} */ get url(): any; /** * Get full url */ get fullUrl(): string; /** * Run middleware */ runMiddleware(): Promise>; /** * Get route handler */ getHandler(): import("../router").RouteHandler; /** * Execute the request */ execute(): Promise; /** * Execute middleware list of current route */ protected executeMiddleware(): Promise>; /** * Collect middlewares for current route */ protected collectMiddlewares(): Middleware[]; /** * Get request input value from query string, params or body */ input(key: string, defaultValue?: any): any; /** * @alias input */ get(key: string, defaultValue?: any): any; /** * Determine if request has input value */ has(key: string): boolean; /** * Set request input value */ set(key: string, value: any): void; /** * Unset request payload keys */ unset(...keys: string[]): this; /** * Get request body */ get body(): any; /** * Get body inputs except files */ get bodyInputs(): any; /** * Get request file in UploadedFile instance */ file(key: string): UploadedFile | UploadedFile[] | null; /** * Get uploaded files from the request for the given name * If the given name is not present in the request, return an empty array */ files(name: string): UploadedFile[]; /** * Get request params */ get params(): any; /** * Get request query */ get query(): any; /** * Get all inputs */ all(): any; /** * Get all inputs except params */ allExceptParams(): any; /** * Get all heavy inputs except params */ heavyExceptParams(): any; /** * Get only heavy inputs, the input with a value */ heavy(): any; /** * Get only the given keys from the request data */ only(keys: string[]): any; /** * Get all request inputs except the given keys */ except(keys: string[]): any; /** * Get boolean input value */ bool(key: string, defaultValue?: boolean): boolean; /** * Get integer input value */ int(key: string, defaultValue?: number): number; /** * Get string input value */ string(key: string, defaultValue?: string): string; /** * Get float input value */ float(key: string, defaultValue?: number): number; /** * Get number input value */ number(key: string, defaultValue?: number): number; /** * Get request ip */ get ip(): any; /** * Detect proper ip */ detectIp(): any; /** * An alias to detectIp */ get realIp(): any; /** * Get request ips */ get ips(): any; /** * Get request referer */ get referer(): any; /** * Get user agent */ get userAgent(): any; /** * Get request headers */ get headers(): any; } //# sourceMappingURL=request.d.ts.map