Implemented queue management calls in RESTful api

This commit is contained in:
RemixDev 2021-05-28 14:15:18 +02:00
parent 7417e3c325
commit b44a3e9a31
8 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,13 @@
import { ApiHandler } from '../../../types'
import { cancelAllDownloads } from '../../../main'
const path = '/cancelAllDownloads'
const handler: ApiHandler['handler'] = async (req, res) => {
cancelAllDownloads()
res.send({ result: true })
}
const apiHandler = { path, handler }
export default apiHandler

View File

@ -1,5 +1,15 @@
import loginArl from './login-arl' import loginArl from './login-arl'
import addToQueue from './addToQueue' import addToQueue from './addToQueue'
import loginWithCredentials from './loginWithCredentials' import loginWithCredentials from './loginWithCredentials'
import cancelAllDownloads from './cancelAllDownloads'
import removeFinishedDownloads from './removeFinishedDownloads'
import removeFromQueue from './removeFromQueue'
export default [loginArl, addToQueue, loginWithCredentials] export default [
loginArl,
addToQueue,
loginWithCredentials,
cancelAllDownloads,
removeFinishedDownloads,
removeFromQueue
]

View File

@ -0,0 +1,13 @@
import { ApiHandler } from '../../../types'
import { clearCompletedDownloads } from '../../../main'
const path = '/removeFinishedDownloads'
const handler: ApiHandler['handler'] = async (req, res) => {
clearCompletedDownloads()
res.send({ result: true })
}
const apiHandler = { path, handler }
export default apiHandler

View File

@ -0,0 +1,18 @@
import { ApiHandler } from '../../../types'
import { cancelDownload } from '../../../main'
const path = '/removeFromQueue'
const handler: ApiHandler['handler'] = async (req, res) => {
const {uuid} = req.query
if (uuid){
cancelDownload(uuid)
res.send({ result: true })
}else{
res.send({ result: false })
}
}
const apiHandler = { path, handler }
export default apiHandler