Add check to validiate if the request is valid

This commit is contained in:
Liam 2022-10-24 11:59:17 +01:00
parent c4ae5d4cf3
commit e7706effdb
3 changed files with 18 additions and 0 deletions

View File

@ -15,6 +15,12 @@ const KEY = "BL_MAP_STAR_";
* @returns
*/
export default async function handler(req, res) {
if (!req.query.hash || !req.query.difficulty || !req.query.characteristic) {
return res.status(404).json({
status: 404,
message: "Invalid request",
});
}
const mapHash = req.query.hash.replace("custom_level_", "").toLowerCase();
const difficulty = req.query.difficulty.replace(" ", "");
const characteristic = req.query.characteristic;

View File

@ -1,6 +1,12 @@
import { getMapData } from "../../../../src/helpers/beatSaverHelpers";
export default async function handler(req, res) {
if (!req.query.hash) {
return res.status(404).json({
status: 404,
message: "Invalid request",
});
}
const mapHash = req.query.hash;
const mapData = await getMapData(mapHash);

View File

@ -16,6 +16,12 @@ const KEY = "SS_MAP_STAR_";
* @returns
*/
export default async function handler(req, res) {
if (!req.query.hash) {
return res.status(404).json({
status: 404,
message: "Invalid request",
});
}
const mapHash = req.query.hash.replace("custom_level_", "").toLowerCase();
const difficulty = req.query.difficulty.replace(" ", "");
const characteristic = req.query.characteristic;