1.0.0 • Published 2 years ago
integreat-adapter-uri v1.0.0
URI adapter for Integreat
Adapter to support URI templates in Integreat.
Getting started
Prerequisits
Requires node v18 and Integreat v1.0.
Installing and using
Install from npm:
npm install integreat-adapter-uriExample of use:
import integreat from 'integreat'
import httpTransporter from 'integreat-transporter-http'
import uriAdapter from 'integreat-adapter-uri'
import defs from './config.js'
const great = Integreat.create(defs, {
transporters: { http: httpTransporter },
adapters: { uri: uriAdapter },
})
// ... and then dispatch actions as usualExample service configuration:
{
id: 'store',
transporter: 'http',
adapters: ['uri'],
options: {,
endpoints: [
{ options: { uri: 'https://api.com/{payload.id}' } } // Will be expanded to e.g. https://api.com/123
]
}URI transformer
The package also includes a transformer, that works exactly like the adapter,
except it is intended for use in mutation pipelines with
{ $transform: 'uri' }. You may use it like this:
Example of use:
import integreat from 'integreat'
import httpTransporter from 'integreat-transporter-http'
import uriTransformer from 'integreat-adapter-uri/transformer.js'
import defs from './config.js'
const great = Integreat.create(defs, {
transporters: { http: httpTransporter },
transformers: { uri: uriTransformer },
})
// In a mutation pipeline:
const mutation = ['meta.options.uri', { $transform: 'uri' }]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.