This commit is contained in:
@ -138,20 +138,24 @@ export const get = async (req, res) => {
|
||||
|
||||
const combined = req.query.q;
|
||||
if (!combined || combined.replace(" ", "").length == 0)
|
||||
return res.status(400).json({ error: "Missing query." });
|
||||
return res.status(400).json({ error: "missing-query" });
|
||||
|
||||
let entryFound = false;
|
||||
let estimatedPrice = 0;
|
||||
let subtable, closestInTable;
|
||||
let gameValue = 0;
|
||||
let gameValue = -1;
|
||||
let returnKeyWord = "";
|
||||
|
||||
combined.split(" ").forEach((arg) => {
|
||||
if (!isNaN(parseInt(arg)) && !gameValue) {
|
||||
if (!isNaN(parseInt(arg)) && gameValue == -1) {
|
||||
gameValue = parseInt(arg);
|
||||
}
|
||||
});
|
||||
|
||||
if (gameValue == -1) {
|
||||
return res.status(400).json({ error: "gameValue-not-found" });
|
||||
}
|
||||
|
||||
priceTable.forEach((price, idx) => {
|
||||
if (price.regex.test(combined) && !entryFound) {
|
||||
entryFound = true;
|
||||
@ -183,8 +187,5 @@ export const get = async (req, res) => {
|
||||
closestInTable,
|
||||
});
|
||||
}
|
||||
} else
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Query could not be matched with anything." });
|
||||
} else return res.status(400).json({ error: "entry-not-found" });
|
||||
};
|
||||
|
Reference in New Issue
Block a user