UNPKG

nuxt-safe-runtime-config

Version:

Validate Nuxt runtime config with Standard Schema at build time

16 lines (15 loc) 780 B
import { $fetch } from "ofetch"; export const DEFAULT_URL = "https://app.shelve.cloud"; export function createShelveClient({ token, url = DEFAULT_URL }) { const base = url.replace(/\/+$/, ""); const headers = { Cookie: `authToken=${token}` }; const get = (path) => $fetch(`${base}${path}`, { headers }); return { getMe: () => get("/api/user/me"), getTeams: () => get("/api/teams"), getProjects: (slug) => get(`/api/teams/${slug}/projects`), getProjectByName: (slug, project) => get(`/api/teams/${slug}/projects/name/${encodeURIComponent(project)}`), getEnvironment: (slug, env) => get(`/api/teams/${slug}/environments/${env}`), getVariables: (slug, projectId, envId) => get(`/api/teams/${slug}/projects/${projectId}/variables/env/${envId}`) }; }