This commit is contained in:
Finn Dittmar 2025-12-17 21:56:17 +01:00 committed by GitHub
commit 8527d9f37d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 93 additions and 22 deletions

View file

@ -86,6 +86,30 @@ class SeriesController {
res.json(req.series.toOldJSON())
}
/**
* GET: /api/series/:id/next-book/:libraryItemId
* Get the next book in a series after the given library item
*
* @param {SeriesControllerRequest} req
* @param {Response} res
*/
async getNextBook(req, res) {
const currentLibraryItemId = req.params.libraryItemId
const libraryItems = req.libraryItemsInSeries
const currentBookIndex = libraryItems.findIndex((li) => li.id === currentLibraryItemId)
if (currentBookIndex === -1) {
return res.status(404).send('Current book not found in series')
}
if (currentBookIndex >= libraryItems.length - 1) {
return res.status(404).send('No next book in series')
}
const nextBook = libraryItems[currentBookIndex + 1]
res.json(nextBook.toOldJSONExpanded())
}
/**
*
* @param {RequestWithUser} req