node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »

koa-spankular

koa-spankular

Über simple middleware for serving a static file with pushState support. Tested on a stack of Koa, Angular, & ui-router.

Should hopefully work with other likeminded frameworks without too much fuzz : )

Installation

$ npm install koa-spankular

Options

The following options are available (and required):

  • dir - the location of your static file.
  • file - the name + extension of your static file.
  • routes - an array of strings matching the routes you wish to serve the static file.

Example

var spank = require('koa-spankular');
var koa = require('koa');
var app = koa();
 
var routes = ["/", "/users", "/about", "/contact"];
 
// app.use(spank(dir, { file: file, routes: routes }); 
 
app.use(spank((__dirname + '/public/'), {
   file: 'index.html',
   routes: routes
}));
 
app.listen(9000);

License

MIT