From 3d409dc6615bf604ccd6e91d868630a75360f887 Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Mon, 15 Apr 2024 09:12:41 -0400 Subject: [PATCH] Update imports to use paths --- JS-SDK/src/index.ts | 2 +- JS-SDK/src/lib/restfulmc.ts | 16 ++++++++-------- JS-SDK/src/lib/webRequest.ts | 8 +++++--- JS-SDK/src/types/server/bedrock-server.d.ts | 2 +- JS-SDK/src/types/server/java-server.d.ts | 2 +- JS-SDK/src/types/server/server.ts | 4 ++-- JS-SDK/tsconfig.json | 7 ++++++- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/JS-SDK/src/index.ts b/JS-SDK/src/index.ts index d0ed23a..cd141a2 100644 --- a/JS-SDK/src/index.ts +++ b/JS-SDK/src/index.ts @@ -1 +1 @@ -export * from "./lib/restfulmc"; +export * from "@/lib/restfulmc"; diff --git a/JS-SDK/src/lib/restfulmc.ts b/JS-SDK/src/lib/restfulmc.ts index a7f8197..5cd430d 100644 --- a/JS-SDK/src/lib/restfulmc.ts +++ b/JS-SDK/src/lib/restfulmc.ts @@ -1,9 +1,9 @@ -import { MojangServerStatus } from "../types/mojang"; -import { CachedPlayer, SkinPart } from "../types/player"; -import { CachedBedrockMinecraftServer } from "../types/server/bedrock-server"; -import { CachedJavaMinecraftServer } from "../types/server/java-server"; -import { Platform } from "../types/server/server"; -import { WebRequest } from "./webRequest"; +import { MojangServerStatus } from "@/types/mojang"; +import { CachedPlayer, SkinPart } from "@/types/player"; +import { CachedBedrockMinecraftServer } from "@/types/server/bedrock-server"; +import { CachedJavaMinecraftServer } from "@/types/server/java-server"; +import { WebRequest } from "@/lib/webRequest"; +import { ServerPlatform } from "@/types/server/server"; /** * Get a player by their username or UUID. @@ -42,10 +42,10 @@ export const getSkinPart = ( * @returns the promised server */ export const getMinecraftServer = ( - platform: Platform, + platform: ServerPlatform, hostname: string ): Promise => - platform === Platform.JAVA + platform === ServerPlatform.JAVA ? new WebRequest( `/server/${platform}/${hostname}` ).execute() diff --git a/JS-SDK/src/lib/webRequest.ts b/JS-SDK/src/lib/webRequest.ts index 26f114c..f6de026 100644 --- a/JS-SDK/src/lib/webRequest.ts +++ b/JS-SDK/src/lib/webRequest.ts @@ -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. @@ -23,7 +23,9 @@ export class WebRequest { */ execute = (): Promise => 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 // Parse as Json diff --git a/JS-SDK/src/types/server/bedrock-server.d.ts b/JS-SDK/src/types/server/bedrock-server.d.ts index a8071a1..1a07d44 100644 --- a/JS-SDK/src/types/server/bedrock-server.d.ts +++ b/JS-SDK/src/types/server/bedrock-server.d.ts @@ -1,4 +1,4 @@ -import { MinecraftServer } from "./server"; +import { MinecraftServer } from "@/types/server/server"; /** * A cacheable {@link BedrockMinecraftServer}. diff --git a/JS-SDK/src/types/server/java-server.d.ts b/JS-SDK/src/types/server/java-server.d.ts index d5e7291..6118b38 100644 --- a/JS-SDK/src/types/server/java-server.d.ts +++ b/JS-SDK/src/types/server/java-server.d.ts @@ -1,4 +1,4 @@ -import { MinecraftServer } from "./server"; +import { MinecraftServer } from "@/types/server/server"; /** * A cacheable {@link JavaMinecraftServer}. diff --git a/JS-SDK/src/types/server/server.ts b/JS-SDK/src/types/server/server.ts index f1d91c9..4765d12 100644 --- a/JS-SDK/src/types/server/server.ts +++ b/JS-SDK/src/types/server/server.ts @@ -1,4 +1,4 @@ -import { ARecord, SRVRecord } from "../dns"; +import { ARecord, SRVRecord } from "@/types/dns"; /** * A model representing a Minecraft server. @@ -114,7 +114,7 @@ type MOTD = { * A platform a Minecraft * server can operate on. */ -export enum Platform { +export enum ServerPlatform { /** * The Java edition of Minecraft. */ diff --git a/JS-SDK/tsconfig.json b/JS-SDK/tsconfig.json index 90f2f8f..5abdb79 100644 --- a/JS-SDK/tsconfig.json +++ b/JS-SDK/tsconfig.json @@ -11,6 +11,11 @@ "allowJs": true, "noEmit": true, "outDir": "dist", - "resolveJsonModule": true + "resolveJsonModule": true, + "paths": { + "@/*": ["./src/*"], + "@/lib/*": ["./src/lib/*"], + "@/types/*": ["./src/types/*"] + } } }