13 lines
451 B
JavaScript
13 lines
451 B
JavaScript
|
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
|