mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2024-11-10 09:13:36 +08:00
refactor(backend/routes/network.js): better routes order
This commit is contained in:
parent
aea4a6a800
commit
de236b45a1
1 changed files with 11 additions and 11 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue