const express = require('express')
const controller = require('../controllers')

const router = express.Router()

router.get('/', (req, res, next) => {
  res.send({ message: 'Hello World!' })
})

router.post('/firmwares/lookFirmware', controller.firmware.postLookFirmware);
router.post('/firmwares/syncFirmware', controller.firmware.postSyncFirmware);

router.post('/v2/periodic/:id', controller.longpolling.postPeriodic);
router.post('/v2/response/:id/:qid', controller.longpolling.postResponse);
router.get('/api/module/:id/:route/:module?', controller.longpolling.getModuleRequest);
router.post('/api/module/:id/:route/:module?', controller.longpolling.postModuleRequest);

router.post('/v2/setData/:id', controller.data.postSetData);
router.post('/v2/setJournal/:id', controller.journal.postSetJournal);
router.post('/v2/ipx-data/:id', controller.ipx.postIpxData);
router.post('/v2/setStatus/:id', controller.status.postSetStatus);

router.post("/v2/get/requests/to/do", controller.grtd.postGetRequestToDo);
router.post("/v2/reportModuleDataSent", controller.grtd.reportModuleDataSent);
router.get("/v2/getModuleConfiguration", controller.grtd.getModuleConfiguration);
router.post("/v2/setModuleConfiguration", controller.grtd.setModuleConfiguration);
router.get("/v2/getModulePrograms", controller.grtd.getModulePrograms);
router.post("/v2/setModulePrograms", controller.grtd.setModulePrograms);

router.all('/api/*', (req, res) => { res.send(503); });

router.all('*', (req, res) => { res.send(404); });

module.exports = router;

