Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A fully customizable Hapi server for Docpad

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
test
.gitignore
.npmignore
History.md
LICENSE.md
Makefile
README.md
package.json

README.md

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-server

Running with pm2 or forever

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

License

Licensed under the incredibly permissive MIT License

Something went wrong with that request. Please try again.