@types/centra
Version:
TypeScript definitions for centra
68 lines (54 loc) • 2.04 kB
Markdown
# Installation
> `npm install --save @types/centra`
# Summary
This package contains type definitions for centra (https://github.com/ethanent/centra).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/centra.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/centra/index.d.ts)
````ts
/// <reference types="node" />
import { IncomingMessage, RequestOptions } from "http";
import { URL } from "url";
interface CentraFactory {
(url: URL | string, method?: string): Centra.Request;
}
declare const Centra: CentraFactory;
declare namespace Centra {
interface Response {
coreRes: IncomingMessage;
headers: IncomingMessage["headers"];
statusCode: IncomingMessage["statusCode"];
body: Buffer;
json(): Promise<any>;
text(): Promise<string>;
}
interface Request {
url: URL;
method: string;
data: string | Buffer | null;
sendDataAs: "form" | "json" | "buffer" | null;
reqHeaders: { [k: string]: string };
streamEnabled: boolean;
compressionEnabled: boolean;
timeoutTime: number | null;
coreOptions: RequestOptions;
query(key: string, value: any): this;
query(params: { [k: string]: any }): this;
path(relativePath: string): this;
body(data: any, sendAs?: "json" | "buffer" | "form"): this;
header(key: string, value: string): this;
header(headers: { [k: string]: string }): this;
timeout(timeMs: number): this;
option<T extends keyof RequestOptions>(key: T, value: RequestOptions[T]): this;
stream(): this;
compress(): this;
send(): Promise<Response>;
}
}
export = Centra;
````
### Additional Details
* Last updated: Mon, 06 Nov 2023 22:41:05 GMT
* Dependencies: [@types/node](https://npmjs.com/package/@types/node)
# Credits
These definitions were written by [Tony Wooster](https://github.com/twooster).