node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »


Hapi Server Plugin for DocPad

A fully customizable Hapi server for docpad.

Usage (more coming soon)

In or docpad.js, you can directly add routes as specified in Hapi Documentation

Hapi plugins can easily be loaded. Plugins can access docpad through For example, to get docpad configuration, or in the router

Also, server configuration can be overriden with the 'config' key

# Require Joi for route validation 
Joi = require('joi');
# Docpad Configuration Object 
module.exports = {
            # router 
            routes: [
                    method: 'POST'
                    path: '/test'
                    handler: (request, reply) ->
                                test: Joi.string().min(3).max(8)
                    method: 'PUT'
                    path: '/hello'
                    handler: (request, reply) ->
            # server plugins 
            plugins: [
                        require: 'good',
                                console: ['request''log''error']
                        require: 'yar',
                                password: 'password'
                        require: './lib/customPlugin',
                                password: 'password'
            # server 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-server

Running with pm2 or forever

forever start node_modules/docpad-plugin-hapi/lib/bin/docpad-hapi-server.js


Licensed under the incredibly permissive MIT License