2021-07-07 19:47:40 +01:00

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"
})
);
}
}