# @rdfc/http-utils-processor-ts

> HTTP util functions to be used within RDF-Connect

Latest version **1.1.0** (published 2026-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rdfc/http-utils-processor-ts
pnpm add @rdfc/http-utils-processor-ts
yarn add @rdfc/http-utils-processor-ts
bun add @rdfc/http-utils-processor-ts
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-03-02 |
| First published | 2024-04-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 9 |
| Unpacked size | 122.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jens Pots |
| Maintainers | smessie, ajuvercr, pietercolpaert, julianrojas87, dexagod |
| Keywords | HTTP, RDF-Connect |

## Links

- npm: https://www.npmjs.com/package/@rdfc/http-utils-processor-ts
- Repository: https://github.com/rdf-connect/http-utils-processor-ts
- Homepage: https://github.com/rdf-connect/http-utils-processor-ts#readme
- Issues: https://github.com/rdf-connect/http-utils-processor-ts/issues
- npm.io page: https://npm.io/package/@rdfc/http-utils-processor-ts

## Dependencies (9)

- [cron](https://npm.io/package/cron.md) ^4.4.0
- [husky](https://npm.io/package/husky.md) ^9.1.7
- [dotenv](https://npm.io/package/dotenv.md) ^17.3.1
- [express](https://npm.io/package/express.md) ^5.2.1
- [ts-node](https://npm.io/package/ts-node.md) ^10.9.2
- [winston](https://npm.io/package/winston.md) ^3.19.0
- [lint-staged](https://npm.io/package/lint-staged.md) ^16.3.1
- [@node-oauth/oauth2-server](https://npm.io/package/@node-oauth/oauth2-server.md) ^5.2.1
- [@node-oauth/express-oauth-server](https://npm.io/package/@node-oauth/express-oauth-server.md) ^4.1.5

## Recent versions

- 1.1.0 (latest) — 2026-03-02
- 1.2.0-alpha.1 (alpha) — 2026-07-15
- 1.0.2 — 2025-10-27
- 1.0.1 — 2025-08-24
- 1.0.0 — 2025-08-23
- 0.1.2 — 2025-02-17
- 0.1.1 — 2025-02-17
- 0.1.0 — 2025-02-17
- 0.0.3 — 2024-09-03
- 0.0.2 — 2024-05-16
- 0.0.1-alpha.2 — 2024-04-05

## README

# http-utils-processor-ts

[![Build and test](https://github.com/jenspots/http-utils-processor-ts/actions/workflows/build-test.yml/badge.svg)](https://github.com/jenspots/http-utils-processor-ts/actions/workflows/build-test.yml) [![Coverage Status](https://coveralls.io/repos/github/jenspots/http-utils-processor-ts/badge.svg?branch=main)](https://coveralls.io/github/jenspots/http-utils-processor-ts?branch=main) [![npm](https://img.shields.io/npm/v/@rdfc/http-utils-processor-ts.svg?style=popout)](https://npmjs.com/package/@rdfc/http-utils-processor-ts)

RDF-Connect Typescript processors for handling HTTP operations. The main processor fetches a URL and writes the response to an output channel. It supports configurable HTTP methods, headers, authentication, and scheduling via cron expressions.

---

## Usage

### Installation

```bash
npm install
npm run build
```

Or install from NPM:

```bash
npm install @rdfc/http-utils-processor-ts
```

---

### Pipeline Configuration Example

```turtle
@prefix rdfc: <https://w3id.org/rdf-connect#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.

### Import the processor definitions
<> owl:imports <./node_modules/@rdfc/http-utils-processor-ts/processors.ttl>.

### Define the channels your processor needs
<out> a rdfc:Writer.

### Define and configure the processor
<fetcher> a rdfc:HttpFetch;
    rdfc:url "https://example.org/api/data";
    rdfc:writer <out>;
    rdfc:options [
        rdfc:method "GET";
        rdfc:headers "Authorization: Bearer TOKEN";
        rdfc:acceptStatusCodes "200-300";
        rdfc:closeOnEnd true;
        rdfc:timeOutMilliseconds 5000;
        rdfc:cron "*/5 * * * *";
        rdfc:runOnInit true;
        rdfc:errorsAreFatal true;
        rdfc:outputAsBuffer false;
        rdfc:auth [
            rdfc:type "basic";
            rdfc:username "user";
            rdfc:password "pass"
        ]
    ].
```

---

## Configuration

### Parameters of `rdfc:HttpFetch`:

- `rdfc:url` (**string**, required): URL(s) to fetch. Can be a single string or an array of strings.
- `rdfc:writer` (**rdfc:Writer**, required): Output channel to write the fetched response.
- `rdfc:options` (**rdfc:HttpFetchOptions**, optional): Optional settings including method, headers, timeout, authentication, cron, and more.

---

### Parameters of `rdfc:HttpFetchOptions`:

- `rdfc:method` (**string**, optional): HTTP method (default: `GET`).
- `rdfc:headers` (**string[]**, optional): Array of header strings (default: `[]`).
- `rdfc:acceptStatusCodes` (**string[]**, optional): List of accepted status codes or ranges, e.g., `["200", "201-300"]` (default: `["200-300"]`).
- `rdfc:closeOnEnd` (**boolean**, optional): Whether to close the writer after execution. Default depends on cron: `true` if no cron, `false` otherwise.
- `rdfc:timeOutMilliseconds` (**integer**, optional): Maximum wait time for a response before throwing a timeout error.
- `rdfc:auth` (**rdfc:HttpFetchAuth**, optional): Authentication configuration (see below).
- `rdfc:cron` (**string**, optional): Cron expression to schedule repeated executions.
- `rdfc:runOnInit` (**boolean**, optional): Run immediately upon initialization if cron is set (default: `false`).
- `rdfc:errorsAreFatal` (**boolean**, optional): Exit on fetch errors (default: `true`).
- `rdfc:outputAsBuffer` (**boolean**, optional): Whether the response is returned as a buffer (default: `false`).

---

### Authentication (`rdfc:HttpFetchAuth`)

Supported types:

#### HTTP Basic Authentication

- `rdfc:type`: `"basic"`
- `rdfc:username`: Username string
- `rdfc:password`: Plaintext password

#### OAuth 2.0 Password Grant

- `rdfc:type`: `"oauth2"`
- `rdfc:endpoint`: URL of the OAuth 2.0 server
- `rdfc:username`: Username string
- `rdfc:password`: Plaintext password

> Credentials are only sent to the authentication endpoint, not to the target URL.

---

## Errors

All errors thrown are of type `HttpFetchError` and include a `HttpUtilsErrorType` enum describing the error nature.

---

## Tests

Use Node.js to run tests:

```bash
npm run build
npm test
```

Some tests interact with real servers and may require credentials via a `.env` file:

```shell
# OAuth 2.0 Password Grant
RINF_USERNAME=
RINF_PASSWORD=

# HTTP Basic Auth
WoRMS_USERNAME=
WoRMS_PASSWORD=

# Set to true to enable real requests
BLUE_BIKE=true
```

Additional test information can be found [here](./tests/README.md).

---
_Source: https://npm.io/package/@rdfc/http-utils-processor-ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
