mowojang 0.3.9 → 0.4.0

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
@@ -38,6 +38,8 @@ const username = await Mowojang.getUsername("14727fae-fbdc-4aff-848c-d2713eb9939
38
38
  All above Functions accept an second Argument containing an optional config object.
39
39
  Cache options can also be passed there via the cache key. All available cache options can be found [here](https://axios-cache-interceptor.js.org/config/request-specifics#cache).
40
40
 
41
+ Note: `getProfiles()` defaults to fetching each profile via individual GET requests to improve reliability. To use the POST bulk endpoint instead, pass `{ usePost: true }` as the second argument to `getProfiles()`.
42
+
41
43
  ## 🗃️ Utility Functions
42
44
 
43
45
  All Utility Functions are exported combined as `utlis.x`.
@@ -65,3 +67,17 @@ All Validator Functions are exported combined as `validate.x`.
65
67
  - [Website](https://matdoes.dev)
66
68
  - [GitHub](https://github.com/mat-1)
67
69
  - [Ko-Fi](https://ko-fi.com/matdoesdev)
70
+
71
+ ## 📡 [Status](https://mowojang-status.pixelic.dev/)
72
+
73
+ <details>
74
+ <summary>Show status badges</summary>
75
+
76
+ - Mowojang API - GET /:username -> ![30d uptime](https://mowojang-status.pixelic.dev/api/v1/endpoints/mowojang_mowojang-api---get--:username/uptimes/30d/badge.svg) ![latency](https://img.shields.io/badge/latency-116ms-blue)
77
+ - Mowojang API - GET /:UUID -> ![30d uptime](https://mowojang-status.pixelic.dev/api/v1/endpoints/mowojang_mowojang-api---get--:uuid/uptimes/30d/badge.svg) ![latency](https://img.shields.io/badge/latency-116ms-blue)
78
+ - Mowojang API - GET /session/minecraft/profile/:UUID -> ![30d uptime](https://mowojang-status.pixelic.dev/api/v1/endpoints/mowojang_mowojang-api---get--session-minecraft-profile-:uuid/uptimes/30d/badge.svg) ![latency](https://img.shields.io/badge/latency-135ms-blue)
79
+ - Mowojang API - GET /users/profiles/minecraft/:username -> ![30d uptime](https://mowojang-status.pixelic.dev/api/v1/endpoints/mowojang_mowojang-api---get--users-profiles-minecraft-:username/uptimes/30d/badge.svg) ![latency](https://img.shields.io/badge/latency-116ms-blue)
80
+ - Mowojang API - POST / - [username,UUID] -> ![30d uptime](https://mowojang-status.pixelic.dev/api/v1/endpoints/mowojang_mowojang-api---post-----[username-uuid]/uptimes/30d/badge.svg) ![latency](https://img.shields.io/badge/latency-115ms-blue)
81
+ - Minecraft - GET /texture/:hash -> ![30d uptime](https://mowojang-status.pixelic.dev/api/v1/endpoints/minecraft_minecraft---get--texture-:hash/uptimes/30d/badge.svg) ![latency](https://img.shields.io/badge/latency-26ms-blue)
82
+
83
+ </details>
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mowojang",
3
- "version": "0.3.9",
3
+ "version": "0.4.0",
4
4
  "description": "A simple JavaScript and TypeScript compatible wrapper for the Mowojang-API.",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "axios-cache-interceptor": "^1.6.2"
33
33
  },
34
34
  "devDependencies": {
35
- "@types/node": "^22.10.7",
35
+ "@types/node": "^25.9.1",
36
36
  "typescript": "^5.7.3"
37
37
  }
38
38
  }
@@ -10,7 +10,9 @@ export default class Client {
10
10
  *
11
11
  * Players considered "INVALID" are excluded from the results
12
12
  */
13
- getProfiles(players: Player[], config?: MowojangRequestConfig): MowojangResponse<MowojangProfile[], undefined>;
13
+ getProfiles(players: Player[], config?: MowojangRequestConfig & {
14
+ usePost?: boolean;
15
+ }): MowojangResponse<MowojangProfile[], undefined>;
14
16
  /**
15
17
  * Returns a Player's Profile consisting of their Username and UUID
16
18
  *
@@ -20,12 +22,12 @@ export default class Client {
20
22
  * A Simple Wrapper to Retrieve Only the UUID of a Player's Profile
21
23
  *
22
24
  */
23
- getUUID(username: Username, config?: MowojangRequestConfig): Promise<null | Username>;
25
+ getUUID(username: Username, config?: MowojangRequestConfig): Promise<null | UUID>;
24
26
  /**
25
27
  * A Simple Wrapper to Retrieve Only the Username of a Player's Profile
26
28
  *
27
29
  */
28
- getUsername(UUID: UUID, config?: MowojangRequestConfig): Promise<null | UUID>;
30
+ getUsername(UUID: UUID, config?: MowojangRequestConfig): Promise<null | Username>;
29
31
  /**
30
32
  * Returns an Array of Player Sessions consisting of their Usernames, UUIDs, Skins and Capes
31
33
  *
@@ -39,23 +39,38 @@ export default class Client {
39
39
  return player.toLowerCase();
40
40
  })
41
41
  .sort();
42
- const fetchResponse = await this.axios.post("https://mowojang.matdoes.dev/", players, {
43
- cache: config?.cache ?? { ttl: 15 * 60 * 1000 },
42
+ const usePost = config?.usePost ?? false;
43
+ if (usePost) {
44
+ const fetchResponse = await this.axios.post("https://mowojang.matdoes.dev/", players, {
45
+ cache: config?.cache ?? { ttl: 15 * 60 * 1000 },
46
+ });
47
+ if (!Array.isArray(fetchResponse?.data))
48
+ return { data: null, error: "UNKNOWN_ERROR" };
49
+ return {
50
+ data: fetchResponse.data.map((player) => {
51
+ return {
52
+ UUID: player.id,
53
+ username: player.name,
54
+ };
55
+ }),
56
+ error: null,
57
+ };
58
+ }
59
+ // Default fallback to GET requests via getProfile()
60
+ const profilePromises = [];
61
+ players.forEach((player) => {
62
+ // @ts-ignore
63
+ profilePromises.push(this.getProfile(player, config));
44
64
  });
45
- if (!Array.isArray(fetchResponse?.data))
46
- return { data: null, error: "UNKOWN_ERROR" };
65
+ const profiles = (await Promise.all(profilePromises)).filter((p) => p.data !== null).map((p) => p.data);
47
66
  return {
48
- data: fetchResponse.data.map((player) => {
49
- return {
50
- UUID: player.id,
51
- username: player.name,
52
- };
53
- }),
67
+ // @ts-ignore
68
+ data: profiles,
54
69
  error: null,
55
70
  };
56
71
  }
57
72
  catch {
58
- return { data: null, error: "UNKOWN_ERROR" };
73
+ return { data: null, error: "UNKNOWN_ERROR" };
59
74
  }
60
75
  }
61
76
  /**
@@ -130,7 +145,7 @@ export default class Client {
130
145
  };
131
146
  }
132
147
  catch {
133
- return { data: null, error: "UNKOWN_ERROR" };
148
+ return { data: null, error: "UNKNOWN_ERROR" };
134
149
  }
135
150
  }
136
151
  /**
@@ -184,7 +199,7 @@ export default class Client {
184
199
  if (isAxiosError(fetchError)) {
185
200
  return { data: null, error: "INVALID_PLAYER" };
186
201
  }
187
- return { data: null, error: "UNKOWN_ERROR" };
202
+ return { data: null, error: "UNKNOWN_ERROR" };
188
203
  });
189
204
  }
190
205
  /**
@@ -3,7 +3,7 @@ import { buildStorage, buildMemoryStorage } from "axios-cache-interceptor";
3
3
  export declare const Client: typeof client;
4
4
  export declare const validate: {
5
5
  player: (player: import("../types/player.js").Player, minimumUsernameLength?: 1 | 2) => boolean;
6
- UUID: (UUID: string) => boolean;
6
+ UUID: (UUID: import("../types/player.js").UUID) => boolean;
7
7
  username: (username: string, minimumLength?: 1 | 2) => boolean;
8
8
  };
9
9
  export declare const utils: {
@@ -1,9 +1,9 @@
1
- import type { Player } from "../types/index.d.ts";
1
+ import type { UUID, Player } from "../types/index.d.ts";
2
2
  /**
3
- * Validates a UUIDv4 string
3
+ * Validates a UUID string both dashed or undashed
4
4
  *
5
5
  */
6
- export declare const validateUUID: (UUID: string) => boolean;
6
+ export declare const validateUUID: (UUID: UUID) => boolean;
7
7
  /**
8
8
  * Validates a Minecraft Username
9
9
  *
@@ -1,6 +1,6 @@
1
1
  import { undashUUID } from "./utils.js";
2
2
  /**
3
- * Validates a UUIDv4 string
3
+ * Validates a UUID string both dashed or undashed
4
4
  *
5
5
  */
6
6
  export const validateUUID = (UUID) => {
@@ -22,5 +22,5 @@ export type MowojangResponse<D, E extends MowojangError | undefined> = Promise<{
22
22
  error: null;
23
23
  } | {
24
24
  data: null;
25
- error: E extends undefined ? "UNKOWN_ERROR" | "INVALID_INPUT" : E | "UNKOWN_ERROR" | "INVALID_INPUT";
25
+ error: E extends undefined ? "UNKNOWN_ERROR" | "INVALID_INPUT" : E | "UNKNOWN_ERROR" | "INVALID_INPUT";
26
26
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mowojang",
3
- "version": "0.3.9",
3
+ "version": "0.4.0",
4
4
  "description": "A simple JavaScript and TypeScript compatible wrapper for the Mowojang-API.",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "axios-cache-interceptor": "^1.6.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "^22.10.7",
31
+ "@types/node": "^25.9.1",
32
32
  "typescript": "^5.7.3"
33
33
  },
34
34
  "scripts": {