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
808 B

2 years ago
/**
* 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 = {
2 years ago
single(entity, response) {
2 years ago
// if data not exists or data is empty redirect to 404
if (!entity.data || entity.data.length === 0) {
2 years ago
return response.redirect('/404')
}
// getting single
entity.data = entity.data[0]
// adding default template for pages
if (!entity.data.template) {
entity.data.template = 'default'
}
response.locals.page = entity
2 years ago
}
}
export default directusResponseHandler