How to use the cozy-client.default.fromOldClient function in cozy-client

To help you get started, we’ve selected a few cozy-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cozy / cozy.github.io / en / ach / libs / runBatch.js View on Github external
const runScript = async (script, domain, globalCtx) => {
  const doctypes = script.getDoctypes()
  const token =
    process.env.BATCH_TOKEN || (await admin.createToken(domain, doctypes))

  const protocol = domain === 'cozy.tools:8080' ? 'http' : 'https'
  const ach = new ACH(token, protocol + '://' + domain, doctypes)
  await ach.connect()
  const client = CozyClient.fromOldClient(ach.client)
  const logger = namespacedLogger(domain)
  return script.run({
    ...globalCtx,
    client,
    logger
  })
}