State from the Command Line

There are several strategies present for acquiring server configuration details including command line options with abbreviations and defaults as well as json config files from multiple locations. We consider all of this initial state here.

A server-side plugin is loaded at server startup and called as each site is launched as an app.

startServer = (params) -> app = params.app argv = params.argv

# Farm

A server can be run as a wiki farm by indicating --farm on the command line. Saying -f is accepted shorthand. The proper way to detect farm mode is by testing argv.farm because either option sets this true where as argv.f is only set true when the shorthand is used.

farm = (req, res, next) -> if argv.farm next() else res.status(404).send {error: 'must be farm'}