mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-23 01:32:58 +01:00
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
|
import express from "express";
|
||
|
import {
|
||
|
getWebdavConfig,
|
||
|
validateWebdavConfig,
|
||
|
} from "../services/webdavConfigService.js";
|
||
|
import * as webdavService from "../services/webdavService.js";
|
||
|
import * as pathTools from "../tools/pathTools.js";
|
||
|
|
||
|
const webdavRouter = express.Router();
|
||
|
|
||
|
webdavRouter.get("/backup/auto", (req, res, next) => {
|
||
|
const config = getWebdavConfig();
|
||
|
validateWebdavConfig(config)
|
||
|
.then(() => {
|
||
|
webdavService
|
||
|
.getBackups(pathTools.auto, config)
|
||
|
.then((value) => {
|
||
|
res.json(value);
|
||
|
})
|
||
|
.catch((reason) => {
|
||
|
res.status(500);
|
||
|
res.json(reason);
|
||
|
});
|
||
|
})
|
||
|
.catch((reason) => {
|
||
|
res.status(500);
|
||
|
res.json(reason);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
webdavRouter.get("/backup/manual", (req, res, next) => {
|
||
|
const config = getWebdavConfig();
|
||
|
validateWebdavConfig(config)
|
||
|
.then(() => {
|
||
|
webdavService
|
||
|
.getBackups(pathTools.manual, config)
|
||
|
.then((value) => {
|
||
|
res.json(value);
|
||
|
})
|
||
|
.catch((reason) => {
|
||
|
res.status(500);
|
||
|
res.json(reason);
|
||
|
});
|
||
|
})
|
||
|
.catch((reason) => {
|
||
|
res.status(500);
|
||
|
res.json(reason);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
export default webdavRouter;
|