This repository has been archived on 2023-11-06. You can view files and clone it, but cannot push or open issues or pull requests.

23 lines
644 B
JavaScript
Raw Normal View History

2022-10-14 20:00:47 +01:00
import Utils from "../../../utils/utils";
export default async function handler(req, res) {
2022-10-14 20:00:47 +01:00
const mapHash = req.query.hash;
2022-10-14 20:00:47 +01:00
const mapData = await Utils.getMapData(mapHash.replace("custom_level_", ""));
if (mapData === undefined) {
// Check if a map hash was provided
2022-10-20 18:27:43 +01:00
return res.status(404).json({
status: 404,
message: "Unknown Map Hash",
});
2022-10-14 20:00:47 +01:00
}
const data = {
// The maps data from the provided map hash
bsr: mapData.id,
2022-10-19 17:00:19 +01:00
songArt: `http://${req.headers.host}/api/beatsaver/art/${mapHash}?ext=${
mapData.versions[0].coverURL.split("/")[3].split(".")[1]
}`,
2022-10-14 20:00:47 +01:00
};
2022-10-20 18:00:27 +01:00
res.status(200).json({ error: false, data: data });
}