hassio-nextcloud-backup/nextcloud_backup/backend/src/routes/homeAssistant.ts

35 lines
772 B
TypeScript
Raw Normal View History

2022-09-27 23:38:40 +02:00
import express from "express";
2023-01-13 16:18:27 +01:00
import * as haOsService from "../services/homeAssistantService.js";
2022-09-27 23:38:40 +02:00
2022-09-29 00:05:53 +02:00
const homeAssistantRouter = express.Router();
2022-09-27 23:38:40 +02:00
2022-09-29 00:05:53 +02:00
homeAssistantRouter.get("/backups/", (req, res, next) => {
2023-01-13 16:18:27 +01:00
haOsService
.getBackups()
.then((value) => {
2022-09-27 23:38:40 +02:00
res.json(value.body.data.backups);
2023-01-13 16:18:27 +01:00
})
.catch((reason) => {
2022-09-27 23:38:40 +02:00
res.status(500);
res.json(reason);
2023-01-13 16:18:27 +01:00
});
});
homeAssistantRouter.get("/addons", (req, res, next) => {
haOsService
.getAddonList()
.then((value) => {
res.json(value.body.data);
2022-09-27 23:38:40 +02:00
})
2023-01-13 16:18:27 +01:00
.catch((reason) => {
res.status(500);
res.json(reason);
});
2022-09-27 23:38:40 +02:00
});
2023-01-13 16:18:27 +01:00
homeAssistantRouter.get("/folders", (req, res, next) => {
res.json(haOsService.getFolderList());
})
2022-09-27 23:38:40 +02:00
2023-01-13 16:18:27 +01:00
export default homeAssistantRouter;