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.
- package/.github/workflows/publish.yml +18 -22
- package/README.md +2 -10
- package/bun.lock +20 -0
- package/lib/{endpoints → src/endpoints}/endpoints.post.d.ts +5 -0
- package/lib/{index.d.ts → src/index.d.ts} +1 -2
- package/lib/{index.js → src/index.js} +1 -2
- package/lib/{interfaces.d.ts → src/interfaces.d.ts} +436 -436
- package/lib/src/requests.d.ts +7 -0
- package/lib/src/requests.js +17 -0
- package/lib/{responses.d.ts → src/responses.d.ts} +1 -1
- package/package.json +13 -19
- package/src/endpoints/endpoints.post.ts +6 -0
- package/src/index.ts +1 -4
- package/src/interfaces.ts +436 -436
- package/src/requests.ts +26 -0
- package/src/responses.ts +1 -1
- package/tsconfig.json +3 -3
- package/LICENSE +0 -504
- package/lib/Client.d.ts +0 -11
- package/lib/Client.js +0 -23
- package/src/Client.ts +0 -30
- /package/lib/{endpoints → src/endpoints}/endpoints.get.d.ts +0 -0
- /package/lib/{endpoints → src/endpoints}/endpoints.get.js +0 -0
- /package/lib/{endpoints → src/endpoints}/endpoints.post.js +0 -0
- /package/lib/{enums.d.ts → src/enums.d.ts} +0 -0
- /package/lib/{enums.js → src/enums.js} +0 -0
- /package/lib/{interfaces.js → src/interfaces.js} +0 -0
- /package/lib/{responses.js → src/responses.js} +0 -0
- /package/lib/{types.d.ts → src/types.d.ts} +0 -0
- /package/lib/{types.js → src/types.js} +0 -0
|
@@ -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.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"name": "retrozy"
|
|
3
|
+
"version": "2.0.8",
|
|
4
|
+
"author": "retrozy",
|
|
5
|
+
"repository": {
|
|
6
|
+
"url": "https://github.com/retrozy1/speedruncom.js"
|
|
8
7
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
};
|