mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-02 21:44:56 +02:00
Clean up ApiRouter adding MiscController, move upload and scan to api endpoints
This commit is contained in:
parent
69fcb103e4
commit
57399bb79e
14 changed files with 299 additions and 270 deletions
|
@ -1,5 +1,6 @@
|
|||
const Logger = require('../Logger')
|
||||
const { reqSupportsWebp } = require('../utils/index')
|
||||
const { ScanResult } = require('../utils/constants')
|
||||
|
||||
class LibraryItemController {
|
||||
constructor() { }
|
||||
|
@ -239,6 +240,18 @@ class LibraryItemController {
|
|||
else res.sendStatus(500)
|
||||
}
|
||||
|
||||
// GET: api/items/:id/scan (Root)
|
||||
async scan(req, res) {
|
||||
if (!req.user.isRoot) {
|
||||
Logger.error(`[LibraryItemController] Non-root user attempted to scan library item`, req.user)
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
var result = await this.scanner.scanLibraryItemById(req.libraryItem.id)
|
||||
res.json({
|
||||
result: Object.keys(ScanResult).find(key => ScanResult[key] == result)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
middleware(req, res, next) {
|
||||
var item = this.db.libraryItems.find(li => li.id === req.params.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue