@nzz/q-server
Version:
__Q__ is a system that lets journalists create visual elements for stories. It is developed by [NZZ Storytelling](https://www.nzz.ch/storytelling) and used in the [NZZ](https://www.nzz.ch) newsroom.
25 lines (23 loc) • 508 B
JavaScript
const Boom = require('boom');
const getDb = require('../db.js').getDb;
const Joi = require('joi');
module.exports = {
path: '/search',
method: 'POST',
config: {
validate: {
payload: Joi.object().required()
},
tags: ['api', 'editor']
},
handler: (request, reply) => {
let db = getDb();
db.search('items', 'search', request.payload, (err, data) => {
if (err) {
return reply(Boom.internal(err));
} else {
return reply(data);
}
})
}
}