docpad-plugin-hapi
v2.4.2
Published
A fully customizable Hapi server for Docpad.
Maintainers
Readme
Hapi Server Plugin for DocPad
A fully customizable Hapi server for docpad.
Usage (more coming soon)
In docpad.coffee or docpad.js, you can directly add routes as specified in Hapi Documentation
Hapi plugins can easily be loaded. Plugins can access docpad through server.app.docpad. For example, to get docpad configuration, server.app.docpad.getConfig() or in the router request.server.app.docpad.getConfig()
Also, server configuration can be overriden with the 'config' key
# Require Joi for route validation
Joi = require('joi');
# Docpad Configuration Object
module.exports = {
plugins:
hapi:
# router
routes: [
{
method: 'POST'
path: '/test'
handler: (request, reply) ->
reply('test');
config:
validate:
payload:
test: Joi.string().min(3).max(8)
},
{
method: 'PUT'
path: '/hello'
handler: (request, reply) ->
reply('hello');
}
]
# server plugins
plugins: [
{
good:
require: 'good',
options:
subscribers:
console: ['request', 'log', 'error']
},
{
yar:
require: 'yar',
options:
cookieOptions:
password: 'password'
},
customPlugin:
require: './lib/customPlugin',
options:
cookieOptions:
password: 'password'
]
# server config
config:
maxSockets: 2000
# clean urls
defaultExtension: 'html' # default value. Specify another extension if desired.Clean URLs
Clean URLs are enabled by default for files with .html extension. To change Clean URL extension, set plugin settings property "defaultExtension"
Deploying to Heroku or other Cloud Hosting
Change Procfile to
web: node_modules/docpad-plugin-hapi/bin/docpad-hapi-serverRunning with pm2 or forever
forever start node_modules/docpad-plugin-hapi/lib/bin/docpad-hapi-server.jsLicense
Licensed under the incredibly permissive MIT License
