Bds Maneger Server Modification #248
22
src/api.js
22
src/api.js
@@ -286,23 +286,15 @@ app.get("/bds/bridge", (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ? /player
|
// ? /player
|
||||||
const GetPlayerJson = (Platform = BdsManegerCore.BdsSettings.GetJsonConfig().server.platform) => ([...{...JSON.parse(fs.readFileSync(BdsManegerCore.BdsSettings.GetPaths("player"), "utf8"))}[Platform]]);
|
|
||||||
app.get("/players", CheckToken, (req, res) => {
|
app.get("/players", CheckToken, (req, res) => {
|
||||||
const { Platform = BdsSettings.GetPlatform(), Player = null, Action = null } = req.query;
|
let PlayerList = JSON.parse(fs.readFileSync(BdsManegerCore.BdsSettings.GetPaths("player"), "utf8"))
|
||||||
let PlayerList = GetPlayerJson(Platform);
|
const { Platform = null, Player = null, Action = null } = req.query;
|
||||||
|
|
||||||
|
if (Platform) PlayerList = PlayerList.filter(PLS => PLS.Platform === Platform);
|
||||||
if (Player) PlayerList = PlayerList.filter(PLS => PLS.Player === Player);
|
if (Player) PlayerList = PlayerList.filter(PLS => PLS.Player === Player);
|
||||||
if (Action) PlayerList = PlayerList.filter(PLS => PLS.Action === Action);
|
if (Action) PlayerList = PlayerList.filter(PLS => PLS.Action === Action);
|
||||||
|
|
||||||
if (Player || Action) {
|
return res.json(PlayerList);
|
||||||
if (PlayerList.length > 0) res.json(PlayerList);
|
|
||||||
else res.status(404).json({
|
|
||||||
Error: "Player not found",
|
|
||||||
querys: req.query
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
res.json(PlayerList);
|
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Players Actions in Backside Manager
|
// Players Actions in Backside Manager
|
||||||
@@ -490,4 +482,4 @@ module.exports.TokensFilePath = path_tokens;
|
|||||||
module.exports.BdsRoutes = {
|
module.exports.BdsRoutes = {
|
||||||
App: app,
|
App: app,
|
||||||
Server: Server
|
Server: Server
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user