How to use the @prisma/fetch-engine.getProxyAgent function in @prisma/fetch-engine

To help you get started, we’ve selected a few @prisma/fetch-engine 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 prisma / prisma2 / cli / introspection / src / prompt / screens / Step60DownloadExample.tsx View on Github external
export async function downloadRepo(organization: string, repo: string, branch: string): Promise {
  const downloadUrl = `https://api.github.com/repos/${organization}/${repo}/tarball/${branch}` // TODO: use master instead of prisma2
  const tmpFile = getTmpFile(`prisma-download-${organization}-${repo}-${branch}.tar.gz`)
  const response = await fetch(downloadUrl, {
    agent: getProxyAgent(downloadUrl),
    headers: {
      'User-Agent': 'prisma/prisma-init',
    },
  })
  await new Promise((resolve, reject) => {
    response.body
      .pipe(fs.createWriteStream(tmpFile))
      .on('error', reject)
      .on('close', resolve)
  })
  return tmpFile
}
github prisma / prisma2 / cli / introspection / src / prompt / utils / useFetch.ts View on Github external
useEffect(() => {
    if (resultCache[url]) {
      setState(resultCache[url])
    } else {
      fetch(url, {
        agent: getProxyAgent(url),
      })
        .then(res => res.json())
        .then(res => {
          const result = transform ? transform(res) : res
          resultCache[url] = result
          setState(result)
        })
    }
  }, [url])

@prisma/fetch-engine

This package is intended for Prisma's internal use

Apache-2.0
Latest version published 11 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages