little fixes (typos, missing config, etc)

This commit is contained in:
AJ ONeal 2016-06-07 10:49:26 -04:00
parent d792404d67
commit e24dd9bac6
7 changed files with 34 additions and 7 deletions

View File

@ -63,6 +63,7 @@ var info = {
, trustProxy: useCaddy ? true : false
, lexConf: letsencrypt
, varpath: path.join(__dirname, '..', '..', 'var')
, etcpath: path.join(__dirname, '..', '..', 'etc')
}
};

View File

@ -46,6 +46,9 @@ module.exports.create = function (opts) {
function walkLe(domainname) {
var PromiseA = require('bluebird');
if (!domainname) {
return PromiseA.reject(new Error('no domainname given for walkLe'));
}
var fs = PromiseA.promisifyAll(require('fs'));
var path = require('path');
var parts = domainname.split('.'); //.replace(/^www\./, '').split('.');

View File

@ -1,6 +1,8 @@
#!/bin/bash
sudo mkdir -p /srv/walnut/{certs,core,letsencrypt,lib,config}
sudo mkdir -p /srv/walnut/{certs,core,letsencrypt,lib,etc,config}
sudo mkdir -p /srv/walnut/etc/org.oauth3.consumer
sudo mkdir -p /srv/walnut/etc/org.oauth3.provider
sudo mkdir -p /srv/walnut/packages/{api,pages,services}
sudo chown -R $(whoami):$(whoami) /srv/walnut

View File

@ -186,7 +186,9 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
//
// TODO handle /accounts/:accountId
//
return PromiseA.resolve(require(apipath).create({}/*pkgConf*/, deps/*pkgDeps*/, myApp/*myApp*/)).then(function (handler) {
return PromiseA.resolve(require(apipath).create({
etcpath: xconfx.etcpath
}/*pkgConf*/, deps/*pkgDeps*/, myApp/*myApp*/)).then(function (handler) {
localCache.pkgs[apiId] = { pkg: pkg, handler: handler || myApp, createdAt: Date.now() };
localCache.pkgs[apiId].handler(req, res, next);
});

View File

@ -87,6 +87,16 @@ module.exports.create = function (app, xconfx, apiFactories, apiDeps) {
localCache.le[req.hostname] = { conf: leAuth, createdAt: Date.now() };
redirectHttps(req, res);
}, function (err) {
console.error('[Error] lib/main.js walkLe');
if (err.stack) {
console.error(err.stack);
}
else {
console.error(new Error('getstack').stack);
console.error(err);
}
res.send({ error: { message: "failed to get tls certificate for '" + (req.hostname || '') + "'" } });
});
}

View File

@ -89,7 +89,7 @@ module.exports.create = function (webserver, xconfx, state) {
// helpers
, allAsync: function () {
return memstore.allASync().then(function (db) {
return memstore.allAsync().then(function (db) {
return Object.keys(db).filter(function (key) {
return 0 === key.indexOf(scope);
}).map(function (key) {
@ -98,14 +98,14 @@ module.exports.create = function (webserver, xconfx, state) {
});
}
, lengthAsync: function () {
return memstore.allASync().then(function (db) {
return memstore.allAsync().then(function (db) {
return Object.keys(db).filter(function (key) {
return 0 === key.indexOf(scope);
}).length;
});
}
, clearAsync: function () {
return memstore.allASync().then(function (db) {
return memstore.allAsync().then(function (db) {
return Object.keys(db).filter(function (key) {
return 0 === key.indexOf(scope);
}).map(function (key) {
@ -145,8 +145,16 @@ module.exports.create = function (webserver, xconfx, state) {
, systemSqlFactory: systemFactory
};
var hostsmap = {};
function log(req, res, next) {
console.log('[worker/log]', req.method, req.headers.host, req.url);
var hostname = (req.hostname || req.headers.host || '').split(':').shift();
console.log('[worker/log]', req.method, hostname, req.url);
if (hostname && !hostsmap[hostname]) {
hostsmap[hostname] = true;
require('fs').writeFile(
require('path').join(__dirname, '..', '..', 'var', 'hostnames', hostname)
, hostname, function () {});
}
next();
}

View File

@ -41,7 +41,7 @@
"app-scoped-ids": "^1.0.1",
"authcodes": "git://github.com/Daplie/authcodes.git",
"authenticator": "^1.0.0",
"bluebird": "2.x",
"bluebird": "3.x",
"body-parser": "1.x",
"btoa": "1.x",
"bytes": "^1.0.0",
@ -75,6 +75,7 @@
"finalhandler": "^0.3.4",
"foreachasync": "5.x",
"fresh": "^0.2.4",
"http2": "^3.3.2",
"human-readable-ids": "1.x",
"inherits": "^2.0.1",
"ipify": "^1.0.5",