Skip to content

fundamentool


node

Namespaces

Classes

Client

Defined in: src/node/request/Client.ts:59

HTTP/HTTPS request client with optional retry logic, HMAC signing, and minimum latency enforcement. Exposes post, get, and delete convenience methods, plus a low-level request method.

Example

ts
const client = new Client({ baseUrl: 'https://api.example.com', retry: true });
const { data } = await client.get('/users', { query: { page: 1 } });

Constructors

Constructor
ts
new Client(options?): Client;

Defined in: src/node/request/Client.ts:60

Parameters
ParameterType
optionsTClientOptions
Returns

Client

Properties

PropertyTypeDefined in
deleteTRequestFnsrc/node/request/Client.ts:255
getTRequestFnsrc/node/request/Client.ts:254
postTRequestFnsrc/node/request/Client.ts:253
request(method, path, options) => Promise<TResponse>src/node/request/Client.ts:252

Response

Defined in: src/node/request/Response.ts:28

Wraps a Node.js http.IncomingMessage and provides lazy bytes(), text(), and json() accessors. Transparently decompresses gzip and deflate content encodings.

Example

ts
const response = Response.provider(incomingMessage);
const data = await response.json();

Constructors

Constructor
ts
new Response(origin?): Response;

Defined in: src/node/request/Response.ts:41

Parameters
ParameterType
origin?any
Returns

Response

Properties

PropertyTypeDefined in
_jsonanysrc/node/request/Response.ts:35
_textstringsrc/node/request/Response.ts:34
headersRecord<string, string>src/node/request/Response.ts:38
statusstringsrc/node/request/Response.ts:37

Methods

bytes()
ts
bytes(): Promise<any>;

Defined in: src/node/request/Response.ts:51

Returns

Promise<any>

json()
ts
json(): any;

Defined in: src/node/request/Response.ts:108

Returns

any

text()
ts
text(): any;

Defined in: src/node/request/Response.ts:80

Returns

any

provider()
ts
static provider(origin?): Response;

Defined in: src/node/request/Response.ts:47

Parameters
ParameterType
origin?any
Returns

Response

Interfaces

IScanPathOptions

Defined in: src/node/scanPath.ts:5

Indexable

ts
[key: string]: any

Properties

PropertyTypeDefined in
each?(event, path) => voidsrc/node/scanPath.ts:7
exclude?(path) => booleansrc/node/scanPath.ts:8
pathstringsrc/node/scanPath.ts:6

ISearchFilesOptions

Defined in: src/node/searchFiles/each.ts:5

Properties

PropertyTypeDefined in
filter?(name, isDir, depth) => booleansrc/node/searchFiles/each.ts:6
iteratee?(path) => voidsrc/node/searchFiles/each.ts:7

Type Aliases

TClientOptions

ts
type TClientOptions = {
  apiSecret?: string;
  baseUrl?: string;
  defaultHeaders?: Record<string, string>;
  minLatency?: number;
  retry?: boolean;
  retryLimit?: number;
  retryTimeoutSec?: number;
  timestampKey?: string;
};

Defined in: src/node/request/Client.ts:19

Properties

apiSecret?
ts
optional apiSecret?: string;

Defined in: src/node/request/Client.ts:25

baseUrl?
ts
optional baseUrl?: string;

Defined in: src/node/request/Client.ts:27

defaultHeaders?
ts
optional defaultHeaders?: Record<string, string>;

Defined in: src/node/request/Client.ts:26

minLatency?
ts
optional minLatency?: number;

Defined in: src/node/request/Client.ts:21

retry?
ts
optional retry?: boolean;

Defined in: src/node/request/Client.ts:20

retryLimit?
ts
optional retryLimit?: number;

Defined in: src/node/request/Client.ts:23

retryTimeoutSec?
ts
optional retryTimeoutSec?: number;

Defined in: src/node/request/Client.ts:22

timestampKey?
ts
optional timestampKey?: string;

Defined in: src/node/request/Client.ts:24


TRequestFn

ts
type TRequestFn = (path, options?) => Promise<TResponse>;

Defined in: src/node/request/Client.ts:36

Parameters

ParameterType
pathstring
options?TRequestOptions

Returns

Promise<TResponse>


TRequestOptions

ts
type TRequestOptions = {
  body?: any;
  headers?: Record<string, string>;
  query?: Record<string, any>;
  sign?: boolean;
};

Defined in: src/node/request/Client.ts:12

Properties

body?
ts
optional body?: any;

Defined in: src/node/request/Client.ts:13

headers?
ts
optional headers?: Record<string, string>;

Defined in: src/node/request/Client.ts:16

query?
ts
optional query?: Record<string, any>;

Defined in: src/node/request/Client.ts:15

sign?
ts
optional sign?: boolean;

Defined in: src/node/request/Client.ts:14


TResponse

ts
type TResponse = {
  data: any;
  headers: Record<string, any>;
  status: number;
};

Defined in: src/node/request/Client.ts:30

Properties

data
ts
data: any;

Defined in: src/node/request/Client.ts:33

headers
ts
headers: Record<string, any>;

Defined in: src/node/request/Client.ts:32

status
ts
status: number;

Defined in: src/node/request/Client.ts:31

Functions

each()

ts
function each(folderPath, options?): Promise<void>;

Defined in: src/node/searchFiles/each.ts:22

Recursively walks over files starting from folderPath, calling iteratee for each file that passes filter.

Parameters

ParameterTypeDescription
folderPathstringRoot directory path to walk.
optionsISearchFilesOptionsOptional filter and iteratee callbacks.

Returns

Promise<void>

Promise resolved when the full walk is complete.

Example

ts
await each('./src', {
  iteratee: (path) => console.log(path),
});

scanPath()

ts
function scanPath(options): Promise<void>;

Defined in: src/node/scanPath.ts:24

Scans directory tree and calls each('found', path) for every file that is not excluded by exclude(path).

Parameters

ParameterTypeDescription
optionsIScanPathOptionsScan options including path, optional each callback and exclude predicate.

Returns

Promise<void>

Promise resolved when the full scan is complete.

Example

ts
await scanPath({
  path: './src',
  each: (event, filePath) => console.log(filePath),
});

searchFilesIndex()

ts
function searchFilesIndex(folderPath, options?): Promise<string[]>;

Defined in: src/node/searchFiles/index.ts:13

Recursively collects file paths starting from folderPath using each.

Parameters

ParameterTypeDescription
folderPathstringRoot folder to scan.
options?Record<string, any>Options forwarded to each, plus any additional settings.

Returns

Promise<string[]>

Promise resolved with an array of collected paths.

MIT License