Update:API status codes and default provider for findCovers route

This commit is contained in:
advplyr 2022-11-20 16:12:30 -06:00
parent 357a63a4d9
commit 70d887bada
2 changed files with 14 additions and 7 deletions

View file

@ -1,3 +1,5 @@
const Logger = require("../Logger")
class SearchController {
constructor() { }
@ -11,11 +13,16 @@ class SearchController {
async findCovers(req, res) {
var query = req.query
var podcast = query.podcast == 1
const podcast = query.podcast == 1
if (!query.title) {
Logger.error(`[SearchController] findCovers: No title sent in query`)
return res.sendStatus(400)
}
var result = null
if (podcast) result = await this.podcastFinder.findCovers(query.title)
else result = await this.bookFinder.findCovers(query.provider, query.title, query.author || null)
else result = await this.bookFinder.findCovers(query.provider || 'google', query.title, query.author || null)
res.json(result)
}