Serve a collection of Pages and Paths in Node.js. Most importantly, it handles interfacing with Dynapack for you so that you can (almost) forget about compilation steps and whatnot (at least that's the hope).
npm install osh-serve
var serve = ;var app =;// app is an Express instance.app;
The serve function accepts a single configuration object with the following properties.
Sample config with default values:
app:dir: processpaths:pages:scripts:serve: trueoutput:prefix: '/';
Optional. If provided, all Page/Path middleware will be mounted to it. If undefined, osh-serve will create its own.
The base directory for all pages and paths; this should be an absolute path. Defaults to current working directory.
Serve these Paths. An array element can be a Path instance or a string pointing to a module that exports a Path instance. The string can be relative to the 'dir' setting.
Each array element is a string pointing to a module that exports a Page instance. The string can be relative to the 'dir' setting.
Beware that pages will not be mounted until after the
'serving' event fires
on the returned Express app.
Options for module bundling; most of the properties on this object are passed directly to Dynapack. The properties on the scripts object are:
If prefix does not start with '/', then it is assumed that the scripts are
delivered by an external server. In this case the
scripts.serve setting is assumed
Where to save the generated bundles. If left unspecified, and
true, we save them in a temporary directory. If unspecified and
false, no bundles are created and your app will serve static pages.