Files
DRB-CnC/Server/routes/nodes.js
2023-07-22 03:57:50 -04:00

38 lines
1.1 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);
// 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 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;