hive-bedrock-api 0.0.4 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # Hive Bedrock API
2
-
3
- An API wrapper for the Hive Minecraft Bedrock Edition server. Which allows you to get stats for leaderboards and players.
4
-
5
- ## Getting started
6
-
7
- ```bash
8
- $ npm install hive-bedrock-api
9
- $ yarn add hive-bedrock-api
10
- ```
1
+ # Hive Bedrock API
2
+
3
+ An API wrapper for the Hive Minecraft Bedrock Edition server. Which allows you to get stats for leaderboards and players.
4
+
5
+ ## Getting started
6
+
7
+ ```bash
8
+ $ npm install hive-bedrock-api
9
+ $ yarn add hive-bedrock-api
10
+ ```
@@ -0,0 +1,6 @@
1
+ export declare type Game = "sky" | "wars" | "hide" | "sg" | "dr" | "murder" | Game[];
2
+ export declare type Mode = "all" | "monthly";
3
+ export declare type PlayerIdentifier = string;
4
+ export declare const API_ENDPOINT: string;
5
+ export declare const API_GAMES: Array<"sky" | "wars" | "hide" | "sg" | "dr" | "murder">;
6
+ export declare const API_MODES: Array<Mode>;
package/lib/config.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.API_MODES = exports.API_GAMES = exports.API_ENDPOINT = void 0;
4
+ exports.API_ENDPOINT = "https://api.playhive.com/v0";
5
+ exports.API_GAMES = ["sky", "wars", "hide", "sg", "dr", "murder"];
6
+ exports.API_MODES = ["all", "monthly"];
@@ -0,0 +1,2 @@
1
+ import { Game, Mode } from "./config";
2
+ export default function getStats(playerIdentifier: string, game: Game, mode: Mode): Promise<"hi" | undefined>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ function getStats(playerIdentifier, game, mode) {
40
+ return __awaiter(this, void 0, void 0, function () {
41
+ return __generator(this, function (_a) {
42
+ if (!Array.isArray(game)) {
43
+ return [2 /*return*/, "hi"];
44
+ }
45
+ return [2 /*return*/];
46
+ });
47
+ });
48
+ }
49
+ exports.default = getStats;
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import getStats from "./getStats";
2
+ import fetchData from "./misc/fetchData";
3
+ export { getStats, fetchData };
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchData = exports.getStats = void 0;
7
+ var getStats_1 = __importDefault(require("./getStats"));
8
+ exports.getStats = getStats_1.default;
9
+ var fetchData_1 = __importDefault(require("./misc/fetchData"));
10
+ exports.fetchData = fetchData_1.default;
@@ -0,0 +1,11 @@
1
+ declare type Game = "sky" | "wars" | "hide" | "sg" | "dr" | "murder";
2
+ declare type APIPath = `/game/all/${Game}/${string}` | `/game/all/${Game}/[playerIdentifier]` | `/game/all/${Game}` | `/game/monthly/${Game}` | `/game/monthly/${Game}/${number}/${number}/${number}/${number}` | `/game/monthly/${Game}/[year]/[month]/[amount]/[skip]` | `/game/monthly/player/${Game}/${string}` | `/game/monthly/player/${Game}/[playerIdentifier]` | `/game/monthly/player/${Game}/${string}/${number}/${number}` | `/game/monthly/player/${Game}/[playerIdentifier]/[year]/[month]`;
3
+ export default function fetchData(apiPath: APIPath): Promise<{
4
+ response: {
5
+ status: any;
6
+ message: any;
7
+ };
8
+ ratelimits: {};
9
+ data: {};
10
+ } | undefined>;
11
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var axios_1 = __importDefault(require("axios"));
43
+ var config_1 = require("../config");
44
+ function fetchData(apiPath) {
45
+ return __awaiter(this, void 0, void 0, function () {
46
+ var request, err_1, _a, status_1, statusText;
47
+ return __generator(this, function (_b) {
48
+ switch (_b.label) {
49
+ case 0:
50
+ _b.trys.push([0, 2, , 3]);
51
+ return [4 /*yield*/, axios_1.default.get(config_1.API_ENDPOINT + apiPath)];
52
+ case 1:
53
+ request = _b.sent();
54
+ return [3 /*break*/, 3];
55
+ case 2:
56
+ err_1 = _b.sent();
57
+ _a = err_1 === null || err_1 === void 0 ? void 0 : err_1.response, status_1 = _a.status, statusText = _a.statusText;
58
+ return [2 /*return*/, {
59
+ response: {
60
+ status: status_1,
61
+ message: statusText,
62
+ },
63
+ ratelimits: {},
64
+ data: {},
65
+ }];
66
+ case 3: return [2 /*return*/];
67
+ }
68
+ });
69
+ });
70
+ }
71
+ exports.default = fetchData;
@@ -0,0 +1,2 @@
1
+ import { PlayerIdentifier } from "../config";
2
+ export default function getAllTimeStats(playerIdentifier: PlayerIdentifier): Promise<void>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ function getAllTimeStats(playerIdentifier) {
40
+ return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
41
+ return [2 /*return*/];
42
+ }); });
43
+ }
44
+ exports.default = getAllTimeStats;
package/package.json CHANGED
@@ -1,12 +1,23 @@
1
- {
2
- "name": "hive-bedrock-api",
3
- "version": "0.0.4",
4
- "description": "An API wrapper for the Hive Minecraft Bedrock Edition server.",
5
- "main": "index.js",
6
- "license": "MIT",
7
- "author": "Cubeedge Studios",
8
- "private": false,
9
- "dependencies": {
10
- "axios": "^0.26.0"
11
- }
12
- }
1
+ {
2
+ "name": "hive-bedrock-api",
3
+ "version": "0.0.7",
4
+ "description": "An API wrapper for the Hive Minecraft Bedrock Edition server.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/CubeEdge-Studios/hive-bedrock-api.git"
10
+ },
11
+ "license": "MIT",
12
+ "author": "Cubeedge Studios",
13
+ "dependencies": {
14
+ "axios": "^0.26.0",
15
+ "typescript": "^4.5.5"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc"
19
+ },
20
+ "files": [
21
+ "lib/**/*"
22
+ ]
23
+ }
package/index.js DELETED
@@ -1,10 +0,0 @@
1
- const axios = require("axios");
2
-
3
- modeule.exports = async function getAlltimeStats() {
4
- const request = await axios.get(
5
- `https://api.playhive.com/v0/game/all/sg/ucdfiddes`
6
- );
7
- const response = request.data;
8
-
9
- return response;
10
- };