hapi-spa

0.2.0 • Public • Published

hapi-spa

Serve a single page app with hapi

Getting Started

Install hapi-spa by either running npm install hapi-spa in your sites working directory or add 'hapi-spa' to the dependencies section of the 'package.json' file and run npm install.

Required permissions

hapi-spa requires the following permissions to be granted on the server for the plugin to work correctly:

  • route
  • events
  • ext

Available options

{
    folder: '/', // Required in plugin options - specifies location of SPA files
    path: '/', // Optional - route path
    index: 'index.html', // Optional - SPA index file
    autoIndex: true, // Optional - default directory handler setting
    redirectToSlash: false, // Optional - disables default directory handler setting
    hash: '/#!/' // Optional - Hash or other leading character SPA router uses
}

An array of options can be used to register multiple single page apps

Example

var Hapi = require('hapi');

var server = new Hapi.Server(8000, { files: { relativeTo: '/' } });

server.pack.require('hapi-spa', { folder: '/var/www/app/'}, function(err) {
  if (err) throw err;
  console.log('loaded hapi-spa');
});

server.start();

Multiple SPAs

var Hapi = require('hapi');

var server = new Hapi.Server(8000, { files: { relativeTo: '/' } });

server.pack.require('hapi-spa', [{ path: '/app1/, folder: '/var/www/app1/'}, { path: '/app2/, folder: '/var/www/app2/'}], function(err) {
  if (err) throw err;
  console.log('loaded hapi-spa');
});

server.start();

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.0
    0
  • 0.1.0
    0
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i hapi-spa

Weekly Downloads

0

Version

0.2.0

License

none

Last publish

Collaborators

  • stongo