/** * directusResponseHandler * * handle response from directus, for http of fastify * * @author Björn Hase * @license http://opensource.org/licenses/MIT The MIT License * @link https://gitea.node001.net/HerrHase/super-fastify-directus.git * */ const directusResponseHandler = { async one(entity, response) { // if data is empty redirect to 404 if (entity.data.length === 0) { return response.redirect('/404') } // getting single entity.data = entity.data[0] // adding default template for pages if (!entity.data.template) { entity.data.template = 'default' } return entity } } export default directusResponseHandler