Update imports to use paths

This commit is contained in:
Braydon 2024-04-15 09:12:41 -04:00
parent 6322af94bb
commit 3d409dc661
7 changed files with 24 additions and 17 deletions

@ -1 +1 @@
export * from "./lib/restfulmc";
export * from "@/lib/restfulmc";

@ -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<CachedJavaMinecraftServer | CachedBedrockMinecraftServer> =>
platform === Platform.JAVA
platform === ServerPlatform.JAVA
? new WebRequest(
`/server/${platform}/${hostname}`
).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.
@ -23,7 +23,9 @@ export class WebRequest {
*/
execute = <T>(): Promise<T> =>
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

@ -1,4 +1,4 @@
import { MinecraftServer } from "./server";
import { MinecraftServer } from "@/types/server/server";
/**
* A cacheable {@link BedrockMinecraftServer}.

@ -1,4 +1,4 @@
import { MinecraftServer } from "./server";
import { MinecraftServer } from "@/types/server/server";
/**
* 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.
@ -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.
*/

@ -11,6 +11,11 @@
"allowJs": true,
"noEmit": true,
"outDir": "dist",
"resolveJsonModule": true
"resolveJsonModule": true,
"paths": {
"@/*": ["./src/*"],
"@/lib/*": ["./src/lib/*"],
"@/types/*": ["./src/types/*"]
}
}
}