Player search

This commit is contained in:
RochesterX
2025-11-17 18:56:31 -05:00
parent 9fd3a76546
commit 310bbc9679
10 changed files with 137 additions and 51 deletions

View File

@@ -98,20 +98,14 @@ app.post("/login", async (req, res) => {
}
});
app.post("/getUsers", authenticate, async (req, res) => {
const { query, category } = req.body;
const allowed = ["Id", "Username", "FirstName", "LastName", "DOB", "Role", "LastLogin", "CreatedAt"];
if (!allowed.includes(category)) {
res.status(500).json({ message: `Illegal category "${category}"`});
}
app.post("/getPlayers", authenticate, async (req, res) => {
const { player } = req.body;
const result = await pool.request()
.input("query", sql.VarChar, query)
.query(`SELECT * FROM Users WHERE ${category} LIKE '%' + @query + '%'`);
.input("query", sql.VarChar, player)
.query(`SELECT * FROM [Player, IMPORTANT] WHERE player_name LIKE '%' + @query + '%'`);
res.status(200).json({ query: query, matches: result.recordset });
res.status(200).json({ query: player, matches: result.recordset });
});
app.post("/getInfo", authenticate, async (req, res) => {