fastify point-of-view
//BASIC TEMPLATE
const fastify = require('fastify')()
fastify.register(require('point-of-view'), {
engine: {
ejs: require('ejs')
}
})
fastify.get('/', (req, reply) => {
reply.view('/templates/index.ejs', { text: 'text' })
})
// With async handler be sure to return the result of reply.view
fastify.get('/', async (req, reply) => {
const t = await something()
return reply.view('/templates/index.ejs', { text: 'text' })
})
fastify.listen(3000, err => {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})