1
0
Fork 0
mirror of https://gitlab.com/Alamantus/Readlebee.git synced 2025-07-04 23:24:16 +02:00
Readlebee/routes/search.js

13 lines
451 B
JavaScript
Raw Normal View History

2019-09-06 17:20:27 -06:00
const SearchController = require('../controllers/search');
async function routes(fastify, options) {
fastify.get('/search', async (request, reply) => {
const searchTerm = typeof request.query.for !== 'undefined' ? request.query.for.trim() : '';
const search = new SearchController(searchTerm);
const results = await search.searchOpenLibrary();
reply.view('search.hbs', { results, searchTerm });
});
}
module.exports = routes