mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-24 09:49:24 +02:00
Fix:Relative file path for single book scans, Change:Route names & refactor api
This commit is contained in:
parent
2194d55cc0
commit
66a490365a
41 changed files with 1057 additions and 986 deletions
31
server/controllers/BackupController.js
Normal file
31
server/controllers/BackupController.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
const Logger = require('../Logger')
|
||||
|
||||
class BackupController {
|
||||
constructor() { }
|
||||
|
||||
async delete(req, res) {
|
||||
if (!req.user.isRoot) {
|
||||
Logger.error(`[ApiController] Non-Root user attempting to delete backup`, req.user)
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
var backup = this.backupManager.backups.find(b => b.id === req.params.id)
|
||||
if (!backup) {
|
||||
return res.sendStatus(404)
|
||||
}
|
||||
await this.backupManager.removeBackup(backup)
|
||||
res.json(this.backupManager.backups.map(b => b.toJSON()))
|
||||
}
|
||||
|
||||
async upload(req, res) {
|
||||
if (!req.user.isRoot) {
|
||||
Logger.error(`[ApiController] Non-Root user attempting to upload backup`, req.user)
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
if (!req.files.file) {
|
||||
Logger.error('[ApiController] Upload backup invalid')
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
this.backupManager.uploadBackup(req, res)
|
||||
}
|
||||
}
|
||||
module.exports = new BackupController()
|
Loading…
Add table
Add a link
Reference in a new issue