New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

hpv

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hpv

hapi promise views

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

hpv

requires node v4 or later

hapi promise view: lets you pass promises to reply.view()

this module is super basic, and probably won't work very well with your code; use this at your own risk! (and open up some issues/PRs to help this module grow)

const hpv = require('hpv')
const handlebars = require('handlebars')

// assuming 'server' is your set up hapi server w/ vision

// wrap server.views object in hpv
server.views(hpv({
  engines: {
    handlebars: handlebars
  }
}))

server.route({
  path: '/',
  method: 'GET',
  handler: (request, reply) => {
    const promise = handleIndex(request, reply)
    reply.view('index', promise)
  }
})

function handleIndex (request, reply) {
  return new Promise((resolve, reject) => {
    resolve({
      nice: 5
    })
  })
}

API

hpv(viewsOptions, options)

  • viewsOptions: configuration object for server.views
    • compileMode is force set to 'async', although you should set compileMode to let hpv know how to wrap the compile function
    • every engine's compile function is wrapped in hpv's custom wrapper that passes through the context
  • options: configuration for hpv
    • allowPassthrough: (default: true) if context promise is not a Promise, don't throw an error and use it as the context for the template

FAQs

Package last updated on 05 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts