speedruncom.js 2.0.6 → 2.0.8

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.
@@ -0,0 +1,7 @@
1
+ import GETEndpoints from './endpoints/endpoints.get.js';
2
+ import POSTEndpoints from './endpoints/endpoints.post.js';
3
+ import Responses from './responses.js';
4
+ type Endpoints = GETEndpoints & POSTEndpoints;
5
+ export declare function get<E extends keyof GETEndpoints, P extends GETEndpoints[E]>(endpoint: E, params: P): Promise<Responses[E]>;
6
+ export declare function post<E extends keyof Endpoints, P extends Endpoints[E]>(endpoint: E, params: P): Promise<E extends keyof Responses ? Responses[E] : void>;
7
+ export {};
@@ -0,0 +1,17 @@
1
+ const objectToBase64 = (obj) => {
2
+ const jsonString = JSON.stringify(obj).replace(/\s+/g, '');
3
+ return Buffer.from(jsonString).toString('base64').replace(/=+$/, '');
4
+ };
5
+ const baseUrl = 'https://www.speedrun.com/api/v2';
6
+ export async function get(endpoint, params) {
7
+ const res = await fetch(`${baseUrl}/${endpoint}?_r=${objectToBase64(params)}`);
8
+ return await res.json();
9
+ }
10
+ export async function post(endpoint, params) {
11
+ const res = await fetch(`${baseUrl}/${endpoint}`, {
12
+ method: "POST",
13
+ headers: { "Content-Type": "application/json" },
14
+ body: JSON.stringify(params)
15
+ });
16
+ return await res.json();
17
+ }
@@ -21,7 +21,7 @@ export default interface Responses {
21
21
  moderators: Interfaces.GameModerator[];
22
22
  platforms: Interfaces.Platform[];
23
23
  regions: Interfaces.Region[];
24
- theme?: Interfaces.Theme[];
24
+ theme?: Interfaces.Theme;
25
25
  users: Interfaces.User[];
26
26
  values: Interfaces.Value[];
27
27
  variables: Interfaces.Variable[];
package/package.json CHANGED
@@ -1,27 +1,21 @@
1
1
  {
2
2
  "name": "speedruncom.js",
3
- "version": "2.0.6",
4
- "description": "WIP NodeJS module for Speedrun's version 2 API.",
5
- "type": "module",
6
- "author": {
7
- "name": "retrozy"
3
+ "version": "2.0.8",
4
+ "author": "retrozy",
5
+ "repository": {
6
+ "url": "https://github.com/retrozy1/speedruncom.js"
8
7
  },
9
- "engines": {
10
- "node": ">=18"
11
- },
12
- "dependencies": {
13
- "axios": "^1.9.0"
8
+ "main": "lib/index.js",
9
+ "devDependencies": {
10
+ "@types/node": "^25.9.3",
11
+ "typescript": "^6.0.3"
14
12
  },
15
- "types": "lib/index.d.ts",
13
+ "description": "WIP NodeJS module for Speedrun's version 2 API.",
14
+ "license": "MIT",
16
15
  "scripts": {
17
- "clean": "rimraf lib",
18
16
  "build": "tsc",
19
- "prepare": "npm run build"
20
- },
21
- "devDependencies": {
22
- "@types/node": "^24.0.13",
23
- "rimraf": "^6.0.1",
24
- "typescript": "^5.8.3"
17
+ "check": "tsc --noEmit"
25
18
  },
26
- "main": "lib/index.js"
19
+ "type": "module",
20
+ "types": "lib/index.d.ts"
27
21
  }
@@ -474,6 +474,12 @@ export default interface POSTEndpoints {
474
474
  verified?: Enums.RunStatus;
475
475
  verifiedById?: string;
476
476
  videoState?: Enums.VideoState;
477
+
478
+ /**
479
+ * The maximum amount of moderation runs per page.
480
+ *
481
+ * @max 100
482
+ */
477
483
  limit: number;
478
484
  page: number;
479
485
  };
package/src/index.ts CHANGED
@@ -1,6 +1,3 @@
1
1
  export * from './enums.js';
2
2
  export * from './interfaces.js';
3
-
4
- import Client from './Client.js';
5
-
6
- export default Client;
3
+ export * from './requests.js'