integreat-io / integreat

Node.js integration layer
Other
14 stars 3 forks source link

Support separate options for transporters and adapters #226

Closed kjellmorten closed 1 year ago

kjellmorten commented 1 year ago

Right now, we only have one options object on the service definitions, that is handed to every transporter and adapter. To make it possible to have separate options for the transporter and different adapters, the options will have some dedicated props:

All other options on the top level will be provided to everyone, together with the designated options.

For example:

{
  accountId: '12345',
  transporter: { uri: 'http://api.com/v1' },
  adapters: {
    xml: { namespaces: { ... } },
  }
}

Here, the transporter will get an options object with accountId and uri, while the xml adapter will get accountId and namespaces.

Transporters also support a separation of incoming and outgoing options. We don't really change that logic here, but will support it on the transporter options too.

kjellmorten commented 1 year ago

The final implementation treats the top level properties only as transporter options, so the only way to pass options to an adapter is through the adapters object. This is clearer, and passing options to adapters is a relative new concept anyway, so there should be rather few cases where this will actually break anything.