UNPKG

prisma-util

Version:

Prisma Util is an easy to use tool that merges multiple Prisma schema files, allows extending of models, resolves naming conflicts both manually and automatically and provides easy access to Prisma commands and timing reports. It's mostly a plug-and-play

47 lines (46 loc) 1.61 kB
import axios from "axios"; export const ROOT = "DavidHancu/prisma-util"; const GitCreator = (root) => { return { Branch: { list: async () => { const res = await queryAxios(`https://api.github.com/repos/${root}/branches`); if (!res.success) return []; return res.data.map(branch => branch.name); }, exists: async (branchName) => { const res = await queryAxios(`https://api.github.com/repos/${root}/branches/${branchName}`); return res.success; } }, File: { get: async (branch, file) => { const res = await queryAxios(`https://raw.githubusercontent.com/${root}/${branch}/${file}`); if (!res.success) return undefined; return res.data; } } }; }; function queryAxios(link) { return new Promise(async (resolve) => { await axios .get(link) .catch((axiosError) => { var _a, _b; resolve({ success: false, status: ((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) ? (_b = axiosError.response) === null || _b === void 0 ? void 0 : _b.status : 404 }); }) .then((axiosResponse) => { resolve({ success: true, data: (typeof axiosResponse == "object") ? axiosResponse.data : axiosResponse }); }); }); } export default GitCreator;