UNPKG

fauna-gql-upload

Version:

Manage your FaunaDB resources in within your project and upload them using a single command

28 lines (23 loc) 618 B
// @ts-ignore import { Client, query } from "faunadb"; import fetch from "cross-fetch"; import { secret } from "./env"; import getEndpoint from "./getEndpoint" async function getClient(){ const { api } = await getEndpoint(); const parts = api.replace("//", "").split(":"); const scheme = parts[0] as "http" | "https"; const domain = parts[1]; const port = parts[2] ? { port: parseInt(parts[2]) } : {}; if(!secret) throw new Error("Secret is not defined.") const client = new Client({ secret, fetch, scheme, domain, ...port }); return client; } export const q = query; export default getClient;