From e5fa3e576f73aa7ad64ef845e42dd83f833aad4b Mon Sep 17 00:00:00 2001 From: SebClem Date: Mon, 22 Jul 2024 11:20:10 +0200 Subject: [PATCH] Fix some http code --- nextcloud_backup/backend/src/routes/action.ts | 3 +-- nextcloud_backup/backend/src/routes/config.ts | 9 +++------ nextcloud_backup/backend/src/routes/homeAssistant.ts | 9 +++------ nextcloud_backup/backend/src/routes/messages.ts | 2 +- .../src/components/settings/BackupConfigForm.vue | 1 - 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/nextcloud_backup/backend/src/routes/action.ts b/nextcloud_backup/backend/src/routes/action.ts index 188af3a..cfbea9a 100644 --- a/nextcloud_backup/backend/src/routes/action.ts +++ b/nextcloud_backup/backend/src/routes/action.ts @@ -13,8 +13,7 @@ actionRouter.post("/backup", (req, res) => { .catch(() => { logger.error("Something wrong !"); }); - res.statusCode = 200; - res.send(); + res.sendStatus(202); }); export default actionRouter; diff --git a/nextcloud_backup/backend/src/routes/config.ts b/nextcloud_backup/backend/src/routes/config.ts index bedf674..44f3da6 100644 --- a/nextcloud_backup/backend/src/routes/config.ts +++ b/nextcloud_backup/backend/src/routes/config.ts @@ -24,12 +24,10 @@ configRouter.put("/backup", (req, res) => { validateBackupConfig(req.body as BackupConfig) .then(() => { saveBackupConfig(req.body as BackupConfig); - res.status(204); - res.send(); + res.status(204).send(); }) .catch((error: ValidationError) => { - res.status(400); - res.json(error.details); + res.status(400).json(error.details); }); }); @@ -44,8 +42,7 @@ configRouter.put("/webdav", (req, res) => { }) .then(() => { saveWebdavConfig(req.body as WebdavConfig); - res.status(204); - res.send(); + res.status(204).send(); }) .catch((error: ValidationError) => { res.status(400); diff --git a/nextcloud_backup/backend/src/routes/homeAssistant.ts b/nextcloud_backup/backend/src/routes/homeAssistant.ts index 7b95d08..e50cf43 100644 --- a/nextcloud_backup/backend/src/routes/homeAssistant.ts +++ b/nextcloud_backup/backend/src/routes/homeAssistant.ts @@ -14,8 +14,7 @@ homeAssistantRouter.get("/backups/", (req, res) => { ); }) .catch((reason) => { - res.status(500); - res.json(reason); + res.status(500).json(reason); }); }); @@ -26,8 +25,7 @@ homeAssistantRouter.get("/backup/:slug", (req, res) => { res.json(value.body.data); }) .catch((reason) => { - res.status(500); - res.json(reason); + res.status(500).json(reason); }); }); @@ -38,8 +36,7 @@ homeAssistantRouter.get("/addons", (req, res) => { res.json(value.body.data); }) .catch((reason) => { - res.status(500); - res.json(reason); + res.status(500).json(reason); }); }); diff --git a/nextcloud_backup/backend/src/routes/messages.ts b/nextcloud_backup/backend/src/routes/messages.ts index 1b9cd8a..3539d9c 100644 --- a/nextcloud_backup/backend/src/routes/messages.ts +++ b/nextcloud_backup/backend/src/routes/messages.ts @@ -11,7 +11,7 @@ messageRouter.patch("/:messageId/readed", (req, res) => { if (messageManager.markReaded(req.params.messageId)) { res.json(messageManager.get()); } else { - res.status(404).send(); + res.sendStatus(404); } }); diff --git a/nextcloud_backup/frontend/src/components/settings/BackupConfigForm.vue b/nextcloud_backup/frontend/src/components/settings/BackupConfigForm.vue index fb37f3d..d1e4025 100644 --- a/nextcloud_backup/frontend/src/components/settings/BackupConfigForm.vue +++ b/nextcloud_backup/frontend/src/components/settings/BackupConfigForm.vue @@ -129,4 +129,3 @@ const { save, loading } = useConfigForm( ); defineExpose({ save }); -@/store/backupConfig