2019-09-12 19:35:43 +02:00
|
|
|
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();
|
|
|
|
});
|
2019-09-13 01:04:50 +02:00
|
|
|
|
|
|
|
fastify.get('/api/books/covers', 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 await books.getInventaireCovers();
|
|
|
|
});
|
2019-09-12 19:35:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = routes
|