# pub-src-http

> HTTP source for pub-server and pub-generator - uses built-in fetch in node and browser

Latest version **3.0.0** (published 2026-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install pub-src-http
pnpm add pub-src-http
yarn add pub-src-http
bun add pub-src-http
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-02-21 |
| First published | 2015-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jürgen Leschner |
| Maintainers | jldec |

## Links

- npm: https://www.npmjs.com/package/pub-src-http
- Repository: https://github.com/jldec/pub-server-monorepo
- Homepage: https://github.com/jldec/pub-server-monorepo#readme
- Issues: https://github.com/jldec/pub-server-monorepo/issues
- npm.io page: https://npm.io/package/pub-src-http

## Recent versions

- 3.0.0 (latest) — 2026-02-21
- 2.0.0 — 2024-09-01
- 1.2.1 — 2022-01-22
- 1.2.0 — 2022-01-22
- 1.1.5 — 2022-01-16
- 1.1.4 — 2020-09-13
- 1.1.3 — 2020-07-26
- 1.1.2 — 2020-04-25
- 1.1.1 — 2020-03-07
- 1.1.0 — 2020-02-23
- 1.0.13 — 2020-02-22
- 1.0.12 — 2019-07-13
- 1.0.11 — 2019-04-06
- 1.0.10 — 2019-02-02
- 1.0.9 — 2019-01-03
- … 10 more at https://npm.io/package/pub-src-http/versions

## README

# pub-src-http

HTTP source for pub-server and pub-generator

* provides `get()` and `put()` for JSON reads and writes over http
* uses built-in fetch in browser (requires node v18 or later)

## src(options)

```javascript
var src = require('pub-src-http');

// instantiate source
// options become properties of source
var source = src( { path:'https://....' } );

source.get(function(err, result) {
  if (err) return console.log(err);
  console.log(result);
});

```
### source.path
- must be set to the URL of the HTTP endpoint

### source.timeout
- not currently implemented

### source.get([options], cb)
- `get()` fetches JSON in a single HTTP GET request from the endpoint in source.path
- the result should be an array of file objects each with a `path:` and a `text:` property
- for non "PUB" type sources, other JSON structures may be retrieved

### source.put(files, [options], cb)
- does nothing unless `writable` is set on the source
- serializes files into JSON and transmits them via HTTP POST to the endpoint in source.path

### options
- use optional options object for fetch options like headers
- use options.url to override endpoint

```javascript
source.put(files, function(err, result) {
  if (err) return console.log(err);
  console.log(result);
});
```

#### configuring authentication
- explicit authentication configuration is not currently supported
- in the browser request cookie credentials are included

---
_Source: https://npm.io/package/pub-src-http · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
