pull/42/head
unknown 2019-03-05 17:00:48 -05:00
parent 6f6942ba15
commit ec489da56b
3 changed files with 1 additions and 25 deletions

View File

@ -56,29 +56,6 @@ module.exports = {
error: e.message
})
}
},
list: async function (req, res) {
try {
const body = req.allParams()
let page = 1
const perPage = 200
if (body.page) {
page = Math.abs(+body.page) || 1
delete body.page
}
const books = await Book.find(body || {}).skip((page * perPage) - perPage).limit(perPage)
if (!books.length) {
throw new HttpError(404, 'No books matching those parameters were found.')
}
return res.json(books)
} catch (e) {
if (e instanceof HttpError) return e.send(res)
return res.status(500).json({
error: e.message
})
}
}
}

View File

@ -27,7 +27,7 @@ module.exports = {
'type': 'application/opds+json',
'rel': 'current'
},
{ 'rel': 'search', 'href': '/api/catalog/search{?title,author,isbn}', 'type': 'application/opds+json', 'templated': true }
{ 'rel': 'search', 'href': 'search{?title,author,isbn}', 'type': 'application/opds+json', 'templated': true }
]
})
},

View File

@ -73,7 +73,6 @@ module.exports.routes = {
'GET /auth/:provider/:action': 'AuthController.callback',
'POST /api/publish': 'BooksController.publish',
'GET /api/books': 'BooksController.list',
'GET /api/catalog': 'CatalogController.navigation',
'GET /api/catalog/new': 'CatalogController.listNew',