mirror of
https://gitlab.com/cyclane/sbdatatracker.git
synced 2025-04-19 12:25:05 +00:00
22 lines
628 B
TypeScript
22 lines
628 B
TypeScript
import type { IncomingMessage, ServerResponse } from "http";
|
|
import { getProfilesByPlayer } from "../../../lib/hypixel";
|
|
import { API_KEY } from "../../../server";
|
|
|
|
export async function get(
|
|
req: IncomingMessage & { params: { player: string } },
|
|
res: ServerResponse
|
|
) {
|
|
let response = await getProfilesByPlayer(API_KEY || "", req.params.player);
|
|
if (response.success && response.profiles !== undefined) {
|
|
res.writeHead(200);
|
|
res.end(JSON.stringify(response.profiles));
|
|
} else {
|
|
res.writeHead(response._response.status);
|
|
res.end(
|
|
JSON.stringify({
|
|
message: "Unsuccessful Hypixel API response"
|
|
})
|
|
);
|
|
}
|
|
}
|