Ajout routes API PUT/DEL

This commit is contained in:
Arnaud Nelissen
2025-09-25 18:41:59 +02:00
parent 73add80cab
commit 3ff1b73cd2
5 changed files with 297 additions and 23 deletions

View File

@@ -24,7 +24,7 @@ const postPrograms = async (req, res, next) => {
const putPrograms = async (req, res, next) => {
try {
var programs = await device.postPrograms(req.params.msn, req.body.programs, req.body.timestamp);
var programs = await device.putPrograms(req.params.msn, req.body.programs, req.body.timestamp);
res.send(programs);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -34,7 +34,7 @@ const putPrograms = async (req, res, next) => {
const deletePrograms = async (req, res, next) => {
///// Emit event to server
try {
const programs = await device.postPrograms(req.params.msn, [], req.body.timestamp);
const programs = await device.deletePrograms(req.params.msn);
res.send(programs);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -63,7 +63,7 @@ const postConfiguration = async (req, res, next) => {
const putConfiguration = async (req, res, next) => {
try {
var configuration = await device.postConfiguration(req.params.msn, req.body.configuration, req.body.timestamp);
var configuration = await device.putConfiguration(req.params.msn, req.body.configuration, req.body.timestamp);
res.send(configuration);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -73,7 +73,7 @@ const putConfiguration = async (req, res, next) => {
const deleteConfiguration = async (req, res, next) => {
///// Emit event to server
try {
const configuration = await device.postConfiguration(req.params.msn, [], req.body.timestamp);
const configuration = await device.deleteConfiguration(req.params.msn);
res.send(configuration);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -102,7 +102,7 @@ const postSlots = async (req, res, next) => {
const putSlots = async (req, res, next) => {
try {
var slots = await device.postSlots(req.params.msn, req.body.slots, req.body.timestamp);
var slots = await device.putSlots(req.params.msn, req.body.slots, req.body.timestamp);
res.send(slots);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -112,7 +112,7 @@ const putSlots = async (req, res, next) => {
const deleteSlots = async (req, res, next) => {
///// Emit event to server
try {
const slots = await device.postSlots(req.params.msn, [], req.body.timestamp);
const slots = await device.deleteSlots(req.params.msn);
res.send(slots);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -141,7 +141,7 @@ const postManualCommand = async (req, res, next) => {
const putManualCommand = async (req, res, next) => {
try {
var manualCommand = await device.postManualCommand(req.params.msn, req.body.manualCommand);
var manualCommand = await device.putManualCommand(req.params.msn, req.body.manualCommand);
res.send(manualCommand);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -151,7 +151,7 @@ const putManualCommand = async (req, res, next) => {
const deleteManualCommand = async (req, res, next) => {
///// Emit event to server
try {
const manualCommand = await device.postManualCommand(req.params.msn, null);
const manualCommand = await device.deleteManualCommand(req.params.msn);
res.send(manualCommand);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -181,7 +181,7 @@ const postStatusCommand = async (req, res, next) => {
const putStatusCommand = async (req, res, next) => {
try {
var statusCommand = await device.postStatusCommand(req.params.msn, req.body.statusCommand);
var statusCommand = await device.putStatusCommand(req.params.msn, req.body.statusCommand);
res.send(statusCommand);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -191,7 +191,7 @@ const putStatusCommand = async (req, res, next) => {
const deleteStatusCommand = async (req, res, next) => {
///// Emit event to server
try {
const statusCommand = await device.postStatusCommand(req.params.msn, null);
const statusCommand = await device.deleteStatusCommand(req.params.msn);
res.send(statusCommand);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -221,7 +221,7 @@ const postAcknowledgedAlerts = async (req, res, next) => {
const putAcknowledgedAlerts = async (req, res, next) => {
try {
var acknowledgedAlerts = await device.postAcknowledgedAlerts(req.params.msn, req.body.acknowledgedAlerts);
var acknowledgedAlerts = await device.putAcknowledgedAlerts(req.params.msn, req.body.acknowledgedAlerts);
res.send(acknowledgedAlerts);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});
@@ -231,7 +231,7 @@ const putAcknowledgedAlerts = async (req, res, next) => {
const deleteAcknowledgedAlerts = async (req, res, next) => {
///// Emit event to server
try {
const acknowledgedAlerts = await device.postAcknowledgedAlerts(req.params.msn, null);
const acknowledgedAlerts = await device.deleteAcknowledgedAlerts(req.params.msn);
res.send(acknowledged);
} catch (error) {
res.status(500).send({message: error.message || "unknown_error"});