*/
validRoutes: /[a-zA-Z][a-zA-Z0-9\-_]*/,
+ /** A map of routes
+ * @prop {Object.Map} routes - all the routes!
+ */
+ routes: {},
+
/** Parameters set on bootup (startHttpServer)
* @prop {string[2]} skelPage - html document split in twain for JS injection
* @prop {string} clientJS - jerverscripps to inject in skelPage for clients
})
this.httpd =
require('https').createServer(this.httpsOpts, this.httpdListener)
+ .listen(conf.port)
})
- this.httpd.listen(conf.port)
- this.httpdRoot =
- conf.httpdRoot ? require('path').normalize(conf.httpdRoot) : undefined
- while (this.httpdRoot[this.httpdRoot.length - 1] == require('path').sep)
- this.httpdRoot = this.httpdRoot.slice(0,-1)
- this.syncReads(conf.skelFile, conf.clientJS, conf.hostJS)
+ if (conf.httpdRoot) {
+ this.httpdRoot = require('path').normalize(conf.httpdRoot)
+ while (this.httpdRoot[this.httpdRoot.length - 1] == require('path').sep)
+ this.httpdRoot = this.httpdRoot.slice(0,-1)
+ }
+ this.syncReads([conf.skelFile, conf.clientJS, conf.hostJS])
.then((results) => {
this.skelPage = results[conf.skelFile].split('<!--STRAPP_SRC-->')
this.clientJS = results[conf.clientJS]
&& this.bindJail != path)
throw new Error(`${routeName}:${path} jailed to ${this.bindJail}`)
if (require('fs').existsSync(path)) {
- this.route[routeName] = {
+ this.routes[routeName] = {
bind: {
path: path,
dir: require('fs').lstatSync(path).isDirectory()
* @arg {Object} [readOpts] - options to pass to fs.readFile()
*/
syncReads: (files, readOpts) => new Promise((resolve,reject) => {
- dlog(`syncReads: ${files}`)
+ dlog(`syncing reads from ${files}`)
let count = 0
let results = {}
const read_cb = (fileName) => (err, data) => {
files.forEach((file) =>
require('fs').readFile(file, readOpts, read_cb(file)))
})
-
}
+
+module.exports = exports