1.2.1 • Published 2 years ago

pub-src-http v1.2.1

Weekly downloads
52
License
MIT
Repository
github
Last release
2 years ago

pub-src-http

CI

HTTP source for pub-server and pub-generator

  • provides get() and put() for JSON reads and writes over http
  • uses node-fetch in node, built-in fetch in browser

src(options)

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
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
1.2.0

2 years ago

1.1.5

2 years ago

1.2.1

2 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.13

4 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

6 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.5.0

9 years ago