A fully customizable Hapi server for docpad.
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 validationJoi=require('joi');
# Docpad Configuration Objectmodule.exports= {
plugins:hapi:# routerroutes: [
{
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 pluginsplugins: [
{
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 configconfig:maxSockets:2000# clean urlsdefaultExtension:'html'# default value. Specify another extension if desired.Clean URLs are enabled by default for files with .html extension. To change Clean URL extension, set plugin settings property "defaultExtension"
Change Procfile to
web: node_modules/docpad-plugin-hapi/bin/docpad-hapi-server
forever start node_modules/docpad-plugin-hapi/lib/bin/docpad-hapi-server.js
Licensed under the incredibly permissiveMIT License