Files
DRB-CnC/Server/routes/nodes.js
Logan Cusano ace762fc76 Finalizing Server webUI
Still needed:
- Way to update clients' versions
- Way to delete nodes
- working dashboard
- working search function
2023-07-22 01:19:54 -04:00

47 lines
1.5 KiB
JavaScript

const express = require('express');
const router = express.Router();
const nodesController = require('../controllers/nodesController');
/* GET nodes the server knows */
router.get('/', nodesController.listAllNodes);
// TODO Need to authenticate this request
/* GET the information the server has on a particular node */
router.get('/:nodeId', nodesController.getNodeInfo);
// Update an existing node
router.put('/:nodeId', nodesController.updateExistingNode);
// Add a system to an existing node
router.post('/:nodeId/systems', nodesController.addNodeSystem);
// Update a system on an existing node
router.put('/:nodeId/systems', nodesController.updateNodeSystem);
// Delete a system from an existing node
router.delete('/:nodeId/systems', nodesController.removeNodeSystem);
// TODO Need to authenticate this request
/* POST a new node to the server
*
* Will create a new DB entry for the node for the server to reference later
* Req. body: {
* "serverInfo": {"ip": "x.x.x.x", port: 0000}
* }
*
* Will return a token for the client to reference when the bot is making requests
* Res. body {
* "serverToken": ""
* }
*/
router.post('/newNode', nodesController.newNode);
// TODO Need to authenticate this request
// Client checkin with the server to update client information
router.post('/nodeCheckIn/:nodeId', nodesController.nodeCheckIn);
// Request a node to check in with the server
router.get('/nodeCheckIn/:nodeId', nodesController.requestNodeCheckIn);
module.exports = router;