Socket
Book a DemoInstallSign in
Socket

integreat-adapter-json

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

integreat-adapter-json

JSON adapter for Integreat

1.0.3
latest
Source
npmnpm
Version published
Weekly downloads
319
101.9%
Maintainers
1
Weekly downloads
 
Created
Source

JSON adapter for Integreat

Adapter that lets Integreat parse and stringify JSON.

npm Version Maintainability

Getting started

Prerequisits

Requires node v18 and Integreat v1.0.

Installing and using

Install from npm:

npm install integreat-adapter-json

Example of use:

import Integreat from 'integreat'
import httpTransporter from 'integreat-transporter-http'
import jsonAdapter from 'integreat-adapter-json'
import defs from './config.js'

const great = Integreat.create(defs, {
  transporters: { http: httpTransporter },
  adapters: { json: jsonAdapter },
})

// ... and then dispatch actions as usual

Example service configuration:

{
  id: 'store',
  transporter: 'http',
  adapters: ['json'],
  options: {
    includeHeaders: true
  },
  endpoints: [
    { options: { uri: 'https://api.com/jsonApi' } }
  ]
}

Data headers for sending with content-type application/json will be set unless you set the includeHeaders option to false (it's true by default). Headers will be set where there is data, unless a content-type header is already set. The case of the header will always be changed to 'Content-Type'.

JSON transformer

The package also includes a transformer, that works exactly like the adapter, except it is intended for use in mutation pipelines with { $transform: 'json' }. You may use it like this:

Example of use:

import integreat from 'integreat'
import httpTransporter from 'integreat-transporter-http'
import jsonTransformer from 'integreat-adapter-json/transformer.js'
import defs from './config.js'

const great = Integreat.create(defs, {
  transporters: { http: httpTransporter },
  transformers: { json: jsonTransformer },
})

// In a mutation pipeline:

const mutation = ['response.data', { $transform: 'json' }]

The includeHeaders option from the adapter, does not apply to the transformer.

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.

Keywords

json

FAQs

Package last updated on 16 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.