move wellKnownJson to domains

after some more thought:
* If app moves to another location, user has to remember to move all this config
* It's not really associated with an app. It's to do with the domain info
* We can put some hints in the UI if app is missing.

part of #703
This commit is contained in:
Girish Ramakrishnan
2020-12-23 15:34:23 -08:00
parent 8a17e13ec4
commit 663e0952fc
24 changed files with 100 additions and 98 deletions
+4 -4
View File
@@ -4,18 +4,18 @@ exports = module.exports = {
get
};
const apps = require('../apps.js'),
const domains = require('../domains.js'),
HttpError = require('connect-lastmile').HttpError;
function get(req, res, next) {
const host = req.headers['host'];
apps.getByFqdn(host, function (error, app) {
domains.get(host, function (error, domain) {
if (error) return next(new HttpError(404, error.message));
const location = req.params[0];
if (!app.wellKnown || !(location in app.wellKnown)) return next(new HttpError(404, 'No custom well-known config'));
if (!domain.wellKnown || !(location in domain.wellKnown)) return next(new HttpError(404, 'No custom well-known config'));
res.status(200).send(app.wellKnown[location]);
res.status(200).send(domain.wellKnown[location]);
});
}