mirror of
https://github.com/tribufu/sdk-js
synced 2025-06-16 18:44:18 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
1a8ffe89bc | |||
6b7525c7b0 | |||
aff56dfad6 | |||
bf2f448dc9 | |||
6b3873dae1 | |||
70cb6c6bc9 |
@ -1,15 +1,17 @@
|
|||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*]
|
[*]
|
||||||
end_of_line = lf
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
max_line_length = 120
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
|
indent_size = 1
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
[*.env*]
|
[.env*]
|
||||||
insert_final_newline = false
|
insert_final_newline = false
|
||||||
|
@ -8,9 +8,7 @@ dotenv.config();
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const tribufu = TribufuApi.fromEnv();
|
const tribufu = TribufuApi.fromEnv();
|
||||||
console.log(
|
console.log(await tribufu.getUserInfo());
|
||||||
await tribufu.getServerByAddressAndQueryPort("mine.tribufu.com", 25565),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tribufu",
|
"name": "tribufu",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"description": "Tribufu JS SDK",
|
"description": "Tribufu JS SDK",
|
||||||
"repository": "https://github.com/Tribufu/TribufuJs",
|
"repository": "https://github.com/Tribufu/TribufuJs",
|
||||||
"author": "Tribufu <contact@Tribufu.com>",
|
"author": "Tribufu <contact@Tribufu.com>",
|
||||||
|
@ -1 +0,0 @@
|
|||||||
import { TribufuApiBase } from "./api.base";
|
|
@ -4,7 +4,7 @@
|
|||||||
"documentGenerator": {
|
"documentGenerator": {
|
||||||
"fromDocument": {
|
"fromDocument": {
|
||||||
"json": "",
|
"json": "",
|
||||||
"url": "http://localhost:5000/v1/openapi.json",
|
"url": "http://localhost:5000/openapi.json",
|
||||||
"output": null,
|
"output": null,
|
||||||
"newLineBehavior": "Auto"
|
"newLineBehavior": "Auto"
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@
|
|||||||
"useLeafType": false,
|
"useLeafType": false,
|
||||||
"classTypes": [],
|
"classTypes": [],
|
||||||
"extendedClasses": [],
|
"extendedClasses": [],
|
||||||
"extensionCode": "api.include.ts",
|
"extensionCode": "include.ts",
|
||||||
"generateDefaultValues": true,
|
"generateDefaultValues": true,
|
||||||
"excludedTypeNames": [],
|
"excludedTypeNames": [],
|
||||||
"excludedParameterNames": [],
|
"excludedParameterNames": [],
|
||||||
@ -67,7 +67,7 @@
|
|||||||
"templateDirectory": null,
|
"templateDirectory": null,
|
||||||
"serviceHost": null,
|
"serviceHost": null,
|
||||||
"serviceSchemes": null,
|
"serviceSchemes": null,
|
||||||
"output": "api.generated.ts",
|
"output": "generated.ts",
|
||||||
"newLineBehavior": "LF"
|
"newLineBehavior": "LF"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,12 +92,10 @@ export abstract class TribufuApiBase {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
protected transformOptions(options: RequestInit) {
|
protected transformOptions(options: RequestInit) {
|
||||||
if (this.apiKey) {
|
options.headers = {
|
||||||
options.headers = {
|
...options.headers,
|
||||||
...options.headers,
|
...this.getHeaders(),
|
||||||
...this.getHeaders(),
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve(options);
|
return Promise.resolve(options);
|
||||||
}
|
}
|
@ -8,7 +8,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
import { TribufuApiBase } from "./api.base";
|
import { TribufuApiBase } from "./base";
|
||||||
|
|
||||||
export class TribufuApiGenerated extends TribufuApiBase {
|
export class TribufuApiGenerated extends TribufuApiBase {
|
||||||
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
|
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
|
||||||
@ -447,7 +447,7 @@ export class TribufuApiGenerated extends TribufuApiBase {
|
|||||||
* Get a list of games.
|
* Get a list of games.
|
||||||
* @return OK
|
* @return OK
|
||||||
*/
|
*/
|
||||||
getGames(): Promise<Application[]> {
|
getGames(): Promise<Game[]> {
|
||||||
let url_ = this.baseUrl + "/v1/games";
|
let url_ = this.baseUrl + "/v1/games";
|
||||||
url_ = url_.replace(/[?&]$/, "");
|
url_ = url_.replace(/[?&]$/, "");
|
||||||
|
|
||||||
@ -465,13 +465,13 @@ export class TribufuApiGenerated extends TribufuApiBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected processGetGames(response: Response): Promise<Application[]> {
|
protected processGetGames(response: Response): Promise<Game[]> {
|
||||||
const status = response.status;
|
const status = response.status;
|
||||||
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
return response.text().then((_responseText) => {
|
return response.text().then((_responseText) => {
|
||||||
let result200: any = null;
|
let result200: any = null;
|
||||||
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Application[];
|
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Game[];
|
||||||
return result200;
|
return result200;
|
||||||
});
|
});
|
||||||
} else if (status !== 200 && status !== 204) {
|
} else if (status !== 200 && status !== 204) {
|
||||||
@ -479,14 +479,14 @@ export class TribufuApiGenerated extends TribufuApiBase {
|
|||||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Promise.resolve<Application[]>(null as any);
|
return Promise.resolve<Game[]>(null as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a game by id.
|
* Get a game by id.
|
||||||
* @return OK
|
* @return OK
|
||||||
*/
|
*/
|
||||||
getGameById(id: string): Promise<Application> {
|
getGameById(id: string): Promise<Game> {
|
||||||
let url_ = this.baseUrl + "/v1/games/{id}";
|
let url_ = this.baseUrl + "/v1/games/{id}";
|
||||||
if (id === undefined || id === null)
|
if (id === undefined || id === null)
|
||||||
throw new Error("The parameter 'id' must be defined.");
|
throw new Error("The parameter 'id' must be defined.");
|
||||||
@ -507,13 +507,13 @@ export class TribufuApiGenerated extends TribufuApiBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected processGetGameById(response: Response): Promise<Application> {
|
protected processGetGameById(response: Response): Promise<Game> {
|
||||||
const status = response.status;
|
const status = response.status;
|
||||||
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
return response.text().then((_responseText) => {
|
return response.text().then((_responseText) => {
|
||||||
let result200: any = null;
|
let result200: any = null;
|
||||||
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Application;
|
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as Game;
|
||||||
return result200;
|
return result200;
|
||||||
});
|
});
|
||||||
} else if (status !== 200 && status !== 204) {
|
} else if (status !== 200 && status !== 204) {
|
||||||
@ -521,7 +521,7 @@ export class TribufuApiGenerated extends TribufuApiBase {
|
|||||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Promise.resolve<Application>(null as any);
|
return Promise.resolve<Game>(null as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2746,6 +2746,40 @@ export interface CryptoViewModel {
|
|||||||
decoded: string | null;
|
decoded: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Game {
|
||||||
|
game_port: number | null;
|
||||||
|
query_port: number | null;
|
||||||
|
rcon_port: number | null;
|
||||||
|
server_count: number;
|
||||||
|
steam_app_id: number | null;
|
||||||
|
steam_server_app_id: number | null;
|
||||||
|
enable_servers: boolean;
|
||||||
|
rust_gamedig_id: string | null;
|
||||||
|
node_gamedig_id: string | null;
|
||||||
|
server_connect_url: string | null;
|
||||||
|
server_tags: string | null;
|
||||||
|
id: string;
|
||||||
|
name: string | null;
|
||||||
|
description: string | null;
|
||||||
|
type: ApplicationType;
|
||||||
|
organization_id: string | null;
|
||||||
|
icon_url: string | null;
|
||||||
|
banner_url: string | null;
|
||||||
|
capsule_image_url: string | null;
|
||||||
|
library_image_url: string | null;
|
||||||
|
parent_id: string | null;
|
||||||
|
slug: string | null;
|
||||||
|
visibility: number;
|
||||||
|
password: string | null;
|
||||||
|
primary: number;
|
||||||
|
user_count: number;
|
||||||
|
achievement_count: number;
|
||||||
|
badge_count: number | null;
|
||||||
|
download_count: number;
|
||||||
|
created: string;
|
||||||
|
updated: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface GameServer {
|
export interface GameServer {
|
||||||
id: string;
|
id: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
@ -2819,6 +2853,7 @@ export interface Group {
|
|||||||
export interface GroupGame {
|
export interface GroupGame {
|
||||||
group_id: string;
|
group_id: string;
|
||||||
application_id: string;
|
application_id: string;
|
||||||
|
application: Application;
|
||||||
stats: any | null;
|
stats: any | null;
|
||||||
acquired: string;
|
acquired: string;
|
||||||
last_used: string | null;
|
last_used: string | null;
|
1
src/api/include.ts
Normal file
1
src/api/include.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
import { TribufuApiBase } from "./base";
|
@ -2,8 +2,8 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import { TRIBUFU_API_URL } from "..";
|
import { TRIBUFU_API_URL } from "..";
|
||||||
import { TribufuApiBase } from "./api.base";
|
import { TribufuApiBase } from "./base";
|
||||||
import { TribufuApiGenerated } from "./api.generated";
|
import { TribufuApiGenerated } from "./generated";
|
||||||
import { TribufuApiOptions } from "../options";
|
import { TribufuApiOptions } from "../options";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,8 +98,6 @@ export class TribufuApi extends TribufuApiGenerated {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const baseUrl = process.env[`TRIBUFU_API_URL`] || null;
|
const baseUrl = process.env[`TRIBUFU_API_URL`] || null;
|
||||||
return TribufuApiBase.debugEnabled() && baseUrl
|
return TribufuApiBase.debugEnabled() && baseUrl ? baseUrl : TRIBUFU_API_URL;
|
||||||
? baseUrl
|
|
||||||
: TRIBUFU_API_URL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ export {
|
|||||||
TribufuApiSingleton,
|
TribufuApiSingleton,
|
||||||
};
|
};
|
||||||
|
|
||||||
export * from "./api/api.base";
|
export * from "./api/base";
|
||||||
export * from "./api/api.generated";
|
export * from "./api/generated";
|
||||||
export * from "./api/api.include";
|
export * from "./api/include";
|
||||||
export * from "./api/index";
|
export * from "./api/index";
|
||||||
export * from "./api/singletion";
|
export * from "./api/singletion";
|
||||||
export * from "./http/headers";
|
export * from "./http/headers";
|
||||||
|
Reference in New Issue
Block a user