/// import { Core as Webda, Executor, SessionCookie, User, Service } from "../index"; import * as http from "http"; import { EventEmitter } from "events"; declare class ClientInfo extends Map { ip: string; userAgent: string; locale: string; referer: string; } declare class HttpContext { host: string; method: string; uri: string; protocol: string; port: number; headers: any; root: string; origin: string; body: any; cookies: any; files: any[]; constructor(host: string, method: string, uri: string, protocol?: string, port?: number, body?: any, headers?: any, files?: any[]); getUrl(): string; getCookies(): any; getPort(): number; getHost(): string; getMethod(): string; getProtocol(): string; getBody(): any; getHeaders(): any; getHeader(name: string): any; setBody(body: any): void; getFullUrl(uri?: string): string; } declare class Cookie { name: string; value: string; options: any; } declare class Context extends EventEmitter { clientInfo: ClientInfo; protected _body: any; private _outputHeaders; private _webda; statusCode: number; _cookie: Map; headers: Map; _route: any; _buffered: boolean; private session; _ended: Promise; _stream: any; _promises: Promise[]; _executor: Executor; _flushHeaders: boolean; _sanitized: any; private body; private _params; private _pathParams; private _serviceParams; files: any[]; private _http; /** * @private * Used in case of Buffer response ( like Lambda ) */ _write(chunk: any, enc: any, next: any): boolean; /** * Set current http context * @param httpContext current http context */ setHttpContext(httpContext: HttpContext): void; reinit(): void; /** * Get current http context */ getHttpContext(): HttpContext; /** * Get output headers */ getResponseHeaders(): any; getRequestParameters(): any; parameter(name: string): any; getParameters(): any; private processParameters; getSession(): SessionCookie; getServiceParameters(): any; getPathParameters(): any; setServiceParameters(params: any): void; setPathParameters(params: any): void; resetResponse(): void; /** * Write data to the client * * @param output If it is an object it will be serializeb with toPublicJSON, if it is a String it will be appended to the result, if it is a buffer it will replace the result * @param ...args any arguments to pass to the toPublicJSON method */ write(output: any, encoding?: string, cb?: (error: Error) => void): boolean; /** * Set a header value * * @param {String} header name * @param {String} value */ setHeader(header: any, value: any): void; /** * Write the http return code and some headers * Those headers are not flushed yet so can still be overwritten * * @param {Number} httpCode to return to the client * @param {Object} headers to add to the response */ writeHead(httpCode: any, headers: any): void; /** * Redirect to another url * @param url */ redirect(url: string): void; /** * For compatibility reason * * @todo Implement the serialization * Not yet handle by the Webda framework */ cookie(param: any, value: any, options: any): void; getResponseCookies(): Map; addAsyncRequest(promise: any): void; isEnded(): Promise; /** * Flush the request * * @emits 'finish' event * @throws Error if the request was already ended */ end(): Promise; getRequestBody(sanitizedOptions?: any): any; getResponseBody(): any; getRequest(): http.IncomingMessage; /** * Get a service from webda * * @see Webda * @param {String} name of the service */ getService(name: any): Service; /** * Get a service from webda * * @see Webda * @param {String} name of the service */ getTypedService(name: any): T; /** * Get the HTTP stream to output raw data * @returns {*} */ getStream(): any; /** * Get the current user from session */ getCurrentUser(): Promise; /** * Get the current user id from session */ getCurrentUserId(): string; /** * Return the webda */ getWebda(): Webda; /** * Get the request locale if found */ getLocale(): string; /** * @ignore * Used by Webda framework to set the current route */ setRoute(route: any): void; getRoute(): any; /** * @param executor {object} Set the current executor for this context */ setExecutor(executor: any): void; /** * @ignore * Used for compatibility with express module */ logIn(): void; /** * @ignore * Used by Webda framework to set the body, session and output stream if known */ constructor(webda: Webda, httpContext: HttpContext, stream?: any); newSession(): SessionCookie; init(): Promise; emitError(err: any): void; } export { Context, ClientInfo, HttpContext };