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.
beatsaber-overlay/pages/api/beatsaver/map.js

20 lines
606 B
JavaScript
Raw Normal View History

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