1.0.1 • Published 3 months ago

integreat-adapter-json v1.0.1

Weekly downloads
30
License
ISC
Repository
github
Last release
3 months ago

JSON adapter for Integreat

Adapter that lets Integreat send and receive content in JSON.

npm Version Build Status Coverage Status Dependencies Status Maintainability

Getting started

Prerequisits

Requires node v8.6 and Integreat v0.7.

Installing and using

Install from npm:

npm install integreat-adapter-json

Example of use:

const integreat = require('integreat')
const jsonAdapter = require('integreat-adapter-json')
const defs = require('./config')

const resources = integreat.mergeResources(integreat.resources(), {
  adapters: { json: jsonAdapter() },
})
const great = integreat(defs, resources)

// ... and then dispatch actions as usual

Example source configuration:

{
  id: 'store',
  adapter: 'json',
  endpoints: [
    { options: { uri: 'https://api.com/jsonApi' } }
  ]
}

Data will be sent with content-type application/json.

An optional logger may be provided to the jsonAdapter() function, to log out the request sent to the service, and its response. The logger must be an object with an info() and an error() function. Both should accept a string message as first argument, and a meta object as the second.

Available endpoint options:

  • uri: The uri to send requests to for this endpoint.
  • baseUri: An option base uri prepended to uri.
  • headers: An object of headers to set on the request.
  • method: Override the http method used to send the request. Default is PUT when the request has a body, otherwise GET.
  • authAsQuery: Set to true to include auth options in query string rather than as request headers. Default is false.
  • retries: Number of times to retry a request. Default is 0.
  • timeout: Milliseconds to wait until a request is timed out. Default is 120000.

Running the tests

The tests can be run with npm test.

Contributing

Please read CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests.

License

This project is licensed under the ISC License - see the LICENSE file for details.

0.4.2

3 months ago

1.0.1

6 months ago

1.0.0

9 months ago

0.7.1

10 months ago

0.7.0

10 months ago

0.6.0

12 months ago

0.5.0

1 year ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.2

4 years ago

0.3.3

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago