UNPKG

rblx.js

Version:

A JavaScript wrapper for interacting with the ROBLOX OpenCloud API.

79 lines (78 loc) 3.26 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const urlcat_1 = __importDefault(require("urlcat")); const axios_1 = __importDefault(require("axios")); const BASE_URL = "https://apis.roblox.com/datastores/v1/universes"; async function main(apiKey, universeid, datastoreName, prefix, limit, cursor, AllScopes) { try { BigInt(universeid); Number(limit); } catch (e) { throw new Error("Invalid universeid: " + universeid); } if (universeid) { const res_url = (0, urlcat_1.default)(BASE_URL, "/:universeid/standard-datastores/datastore/entries?datastoreName=:datastoreName", { universeid, datastoreName }); const config = { headers: { "x-api-key": apiKey } }; const response = await axios_1.default.get(res_url, config); return await response.data; } if (prefix) { const res_url = (0, urlcat_1.default)(BASE_URL, "/:universeid/standard-datastores?datastoreName=:datastoreName&prefix=:prefix", { universeid, prefix }); const config = { headers: { "x-api-key": apiKey } }; const response = await axios_1.default.get(res_url, config); return await response.data; } if (limit) { const res_url = (0, urlcat_1.default)(BASE_URL, "/:universeid/standard-datastores?datastoreName=:datastoreName&limit=:limit", { universeid, limit }); const config = { headers: { "x-api-key": apiKey } }; const response = await axios_1.default.get(res_url, config); return await response.data; } if (cursor) { const res_url = (0, urlcat_1.default)(BASE_URL, "/:universeid/standard-datastores?datastoreName=:datastoreName&cursor=:cursor", { universeid, cursor }); const config = { headers: { "x-api-key": apiKey } }; const response = await axios_1.default.get(res_url, config); return await response.data; } if (AllScopes) { const res_url = (0, urlcat_1.default)(BASE_URL, "/:universeid/standard-datastores?datastoreName=:datastoreName&AllScopes=:AllScopes", { universeid, AllScopes }); const config = { headers: { "x-api-key": apiKey } }; const response = await axios_1.default.get(res_url, config); return await response.data; } if (prefix && limit && cursor && AllScopes) { const res_url = (0, urlcat_1.default)(BASE_URL, "/:universeid/standard-datastores?datastoreName=:datastoreName&prefix=:prefix&limit=:limit&cursor=:cursor&AllScopes=:AllScopes", { universeid, prefix, limit, cursor, AllScopes }); const config = { headers: { "x-api-key": apiKey } }; const response = await axios_1.default.get(res_url, config); return await response.data; } } exports.default = main;