You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
760 B

/**
* directusResponseHandler
*
* handle response from directus, for http of fastify
*
* @author Björn Hase <me@herr-hase.wtf>
* @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