@curveball/core
Version:
Curveball is a framework writting in Typescript for Node.js
45 lines (44 loc) • 1.66 kB
TypeScript
import { Readable } from 'node:stream';
import { Request } from '@curveball/kernel';
import { NodeHttpRequest } from './http-utils.js';
export declare class NodeRequest<T> extends Request<T> {
/**
* Node.js Request object
*/
private inner;
constructor(inner: NodeHttpRequest, origin: string);
/**
* This function returns the request body.
*
* If encoding is not specified, this function returns a Buffer. If encoding
* is specified, it will return a string.
* This function returns the request body.
*
* If encoding is not specified, this function returns a Buffer. If encoding
* is specified, it will return a string.
*
* You can only call this function once. Most likely you'll want a single
* middleware that calls this function and then sets `body`.
*/
rawBody(encoding?: string, limit?: string): Promise<string>;
rawBody(encoding?: undefined, limit?: string): Promise<Buffer>;
/**
* getStream returns a Node.js readable stream.
*
* A stream can typically only be read once.
*/
getStream(): Readable;
/**
* Returns the IP address of the HTTP client.
*
* If trustProxy is set to true, it means this server is running behind a
* proxy, and the X-Forwarded-For header should be used instead.
*
* If trustProxy is not set, it defaults to false unless the
* CURVEBALL_TRUSTPROXY environment variable is set. Using an environment
* variable is a good idea for this as having a proxy may be environment
* dependent.
*/
ip(trustProxy?: boolean): string;
}
export default NodeRequest;