Adapter to support URI templates in Integreat.
Requires node v18 and Integreat v1.0.
Install from npm:
npm install integreat-adapter-uri
Example 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 usual
Example 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
]
}
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' }]
The tests can be run with npm test
.
Please read CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests.
This project is licensed under the ISC License - see the LICENSE file for details.