refactor(backend/routes/network.js): better routes order

This commit is contained in:
dec0dOS 2021-04-17 18:47:38 +03:00
parent aea4a6a800
commit de236b45a1

View file

@ -22,6 +22,17 @@ router.get("/", auth.isAuthorized, async function (req, res) {
});
});
// get network
router.get("/:nwid", auth.isAuthorized, async function (req, res) {
const nwid = req.params.nwid;
const data = await network.getNetworksData([nwid]);
if (data[0]) {
res.send(data[0]);
} else {
res.status(404).send({ error: "Network not found" });
}
});
// create new network
router.post("/", auth.isAuthorized, async function (req, res) {
let reqData = req.body;
@ -42,17 +53,6 @@ router.post("/", auth.isAuthorized, async function (req, res) {
});
});
// get network
router.get("/:nwid", auth.isAuthorized, async function (req, res) {
const nwid = req.params.nwid;
const data = await network.getNetworksData([nwid]);
if (data[0]) {
res.send(data[0]);
} else {
res.status(404).send({ error: "Network not found" });
}
});
// update network
router.post("/:nwid", auth.isAuthorized, async function (req, res) {
const nwid = req.params.nwid;