@toolyhub/apiesync
v1.0.8
Published
Example of use ```ts const apiesyncClient = new ApiesyncClient<D, object>(settings, ds, () => ({ logError: console.error, logInformation: console.info }), { fetch })
Downloads
2
Readme
Apiesync nodejs package
Description
Example of use
const apiesyncClient = new ApiesyncClient<D, object>(settings, ds, () => ({
logError: console.error, logInformation: console.info
}), { fetch })
const { configuration, eventHandler } = apiesyncClient
const serviceName = 'shopify'
const groupName = 'shopify'
const group = await configuration.setModuleMapping(serviceName, [{
ClientName: Order.name,
GroupName: groupName,
ServiceName: 'order',
EnableCreationOnClientSide: true,
EnableCreationOnServiceSide: false,
}])
await configuration.setFieldsMapping(serviceName, Order.name, [{
serviceName: 'id',
clientName: 'shopifyId',
}])
await configuration.setFieldsMapping(serviceName, Order.name, [{
serviceName: 'name',
clientName: 'name',
}])
await configuration.setFieldsMapping(serviceName, Order.name, [{
serviceName: 'note_attributes',
clientName: 'note_attributes',
}])
await configuration.setFieldsMapping(serviceName, Order.name, [{
serviceName: 'updated_at',
clientName: 'updatedAt',
}])
const sqsGroup = group.sqsGroups.find(g => g.title === groupName)!
const serve = async () => {
while (true) {
await eventHandler.handleEventsAsync(sqsGroup)
}
}
const p = serve()
await p