initital commit
This commit is contained in:
25
src/server/mojang.ts
Normal file
25
src/server/mojang.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { MinecraftUtils } from "..";
|
||||
import WebRequest from "../common/WebRequest";
|
||||
import { CachedEndpointStatus } from "../types/cache/cachedEndpointStatus";
|
||||
|
||||
export default class MojangTools {
|
||||
public endpointStatusEndpoint = MinecraftUtils.API_ENDPOINT + "/mojang/status";
|
||||
|
||||
/**
|
||||
* Gets the Mojang API status.
|
||||
*
|
||||
* @returns the Mojang API status
|
||||
*/
|
||||
public getMojangEndpointStatus(): Promise<CachedEndpointStatus> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const response = await WebRequest.get(this.endpointStatusEndpoint);
|
||||
const data = response.data;
|
||||
|
||||
if (response.status !== 200) {
|
||||
reject(null);
|
||||
return;
|
||||
}
|
||||
resolve(data);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user