mirror of
https://gitlab.com/Alamantus/Readlebee.git
synced 2025-04-27 22:02:59 +02:00
13 lines
571 B
JavaScript
13 lines
571 B
JavaScript
|
const BooksController = require('../controllers/books');
|
||
|
|
||
|
async function routes(fastify, options) {
|
||
|
fastify.get('/api/books', async (request, reply) => {
|
||
|
const bookURI = typeof request.query.uri !== 'undefined' ? request.query.uri.trim() : '';
|
||
|
const language = typeof request.query.lang !== 'undefined' ? request.query.lang.trim().split('-')[0] : undefined; // Get base language in cases like 'en-US'
|
||
|
const books = new BooksController(fastify.siteConfig.inventaireDomain, bookURI, language);
|
||
|
|
||
|
return books.getBookData();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
module.exports = routes
|