Fix some http code

This commit is contained in:
SebClem 2024-07-22 11:20:10 +02:00
parent 5af1aa6fba
commit e5fa3e576f
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
5 changed files with 8 additions and 16 deletions

View File

@ -13,8 +13,7 @@ actionRouter.post("/backup", (req, res) => {
.catch(() => { .catch(() => {
logger.error("Something wrong !"); logger.error("Something wrong !");
}); });
res.statusCode = 200; res.sendStatus(202);
res.send();
}); });
export default actionRouter; export default actionRouter;

View File

@ -24,12 +24,10 @@ configRouter.put("/backup", (req, res) => {
validateBackupConfig(req.body as BackupConfig) validateBackupConfig(req.body as BackupConfig)
.then(() => { .then(() => {
saveBackupConfig(req.body as BackupConfig); saveBackupConfig(req.body as BackupConfig);
res.status(204); res.status(204).send();
res.send();
}) })
.catch((error: ValidationError) => { .catch((error: ValidationError) => {
res.status(400); res.status(400).json(error.details);
res.json(error.details);
}); });
}); });
@ -44,8 +42,7 @@ configRouter.put("/webdav", (req, res) => {
}) })
.then(() => { .then(() => {
saveWebdavConfig(req.body as WebdavConfig); saveWebdavConfig(req.body as WebdavConfig);
res.status(204); res.status(204).send();
res.send();
}) })
.catch((error: ValidationError) => { .catch((error: ValidationError) => {
res.status(400); res.status(400);

View File

@ -14,8 +14,7 @@ homeAssistantRouter.get("/backups/", (req, res) => {
); );
}) })
.catch((reason) => { .catch((reason) => {
res.status(500); res.status(500).json(reason);
res.json(reason);
}); });
}); });
@ -26,8 +25,7 @@ homeAssistantRouter.get("/backup/:slug", (req, res) => {
res.json(value.body.data); res.json(value.body.data);
}) })
.catch((reason) => { .catch((reason) => {
res.status(500); res.status(500).json(reason);
res.json(reason);
}); });
}); });
@ -38,8 +36,7 @@ homeAssistantRouter.get("/addons", (req, res) => {
res.json(value.body.data); res.json(value.body.data);
}) })
.catch((reason) => { .catch((reason) => {
res.status(500); res.status(500).json(reason);
res.json(reason);
}); });
}); });

View File

@ -11,7 +11,7 @@ messageRouter.patch("/:messageId/readed", (req, res) => {
if (messageManager.markReaded(req.params.messageId)) { if (messageManager.markReaded(req.params.messageId)) {
res.json(messageManager.get()); res.json(messageManager.get());
} else { } else {
res.status(404).send(); res.sendStatus(404);
} }
}); });

View File

@ -129,4 +129,3 @@ const { save, loading } = useConfigForm(
); );
defineExpose({ save }); defineExpose({ save });
</script> </script>
@/store/backupConfig