Update imports to use paths
This commit is contained in:
parent
6322af94bb
commit
3d409dc661
@ -1 +1 @@
|
|||||||
export * from "./lib/restfulmc";
|
export * from "@/lib/restfulmc";
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { MojangServerStatus } from "../types/mojang";
|
import { MojangServerStatus } from "@/types/mojang";
|
||||||
import { CachedPlayer, SkinPart } from "../types/player";
|
import { CachedPlayer, SkinPart } from "@/types/player";
|
||||||
import { CachedBedrockMinecraftServer } from "../types/server/bedrock-server";
|
import { CachedBedrockMinecraftServer } from "@/types/server/bedrock-server";
|
||||||
import { CachedJavaMinecraftServer } from "../types/server/java-server";
|
import { CachedJavaMinecraftServer } from "@/types/server/java-server";
|
||||||
import { Platform } from "../types/server/server";
|
import { WebRequest } from "@/lib/webRequest";
|
||||||
import { WebRequest } from "./webRequest";
|
import { ServerPlatform } from "@/types/server/server";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a player by their username or UUID.
|
* Get a player by their username or UUID.
|
||||||
@ -42,10 +42,10 @@ export const getSkinPart = (
|
|||||||
* @returns the promised server
|
* @returns the promised server
|
||||||
*/
|
*/
|
||||||
export const getMinecraftServer = (
|
export const getMinecraftServer = (
|
||||||
platform: Platform,
|
platform: ServerPlatform,
|
||||||
hostname: string
|
hostname: string
|
||||||
): Promise<CachedJavaMinecraftServer | CachedBedrockMinecraftServer> =>
|
): Promise<CachedJavaMinecraftServer | CachedBedrockMinecraftServer> =>
|
||||||
platform === Platform.JAVA
|
platform === ServerPlatform.JAVA
|
||||||
? new WebRequest(
|
? new WebRequest(
|
||||||
`/server/${platform}/${hostname}`
|
`/server/${platform}/${hostname}`
|
||||||
).execute<CachedJavaMinecraftServer>()
|
).execute<CachedJavaMinecraftServer>()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ErrorResponse } from "../types/generic";
|
import { ErrorResponse } from "@/types/generic";
|
||||||
|
|
||||||
const ENDPOINT = "https://mc.rainnny.club"; // The API endpoint to use
|
const API_ENDPOINT = "https://mc.rainnny.club"; // The API endpoint to use
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a web request to the API.
|
* Make a web request to the API.
|
||||||
@ -23,7 +23,9 @@ export class WebRequest {
|
|||||||
*/
|
*/
|
||||||
execute = <T>(): Promise<T> =>
|
execute = <T>(): Promise<T> =>
|
||||||
new Promise(async (resolve, reject) => {
|
new Promise(async (resolve, reject) => {
|
||||||
const response: Response = await fetch(`${ENDPOINT}/${this.endpoint}`); // Request the player
|
const response: Response = await fetch(
|
||||||
|
`${API_ENDPOINT}/${this.endpoint}`
|
||||||
|
); // Send the request
|
||||||
const contentType: string | null = response.headers.get("Content-Type"); // Get the response content type
|
const contentType: string | null = response.headers.get("Content-Type"); // Get the response content type
|
||||||
|
|
||||||
// Parse as Json
|
// Parse as Json
|
||||||
|
2
JS-SDK/src/types/server/bedrock-server.d.ts
vendored
2
JS-SDK/src/types/server/bedrock-server.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
import { MinecraftServer } from "./server";
|
import { MinecraftServer } from "@/types/server/server";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A cacheable {@link BedrockMinecraftServer}.
|
* A cacheable {@link BedrockMinecraftServer}.
|
||||||
|
2
JS-SDK/src/types/server/java-server.d.ts
vendored
2
JS-SDK/src/types/server/java-server.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
import { MinecraftServer } from "./server";
|
import { MinecraftServer } from "@/types/server/server";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A cacheable {@link JavaMinecraftServer}.
|
* A cacheable {@link JavaMinecraftServer}.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ARecord, SRVRecord } from "../dns";
|
import { ARecord, SRVRecord } from "@/types/dns";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A model representing a Minecraft server.
|
* A model representing a Minecraft server.
|
||||||
@ -114,7 +114,7 @@ type MOTD = {
|
|||||||
* A platform a Minecraft
|
* A platform a Minecraft
|
||||||
* server can operate on.
|
* server can operate on.
|
||||||
*/
|
*/
|
||||||
export enum Platform {
|
export enum ServerPlatform {
|
||||||
/**
|
/**
|
||||||
* The Java edition of Minecraft.
|
* The Java edition of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,11 @@
|
|||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true,
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"],
|
||||||
|
"@/lib/*": ["./src/lib/*"],
|
||||||
|
"@/types/*": ["./src/types/*"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user