email autoconfig

This commit is contained in:
Girish Ramakrishnan
2021-01-28 13:27:50 -08:00
parent adfb506af4
commit ef68cb70c0
4 changed files with 78 additions and 7 deletions
+5 -7
View File
@@ -4,18 +4,16 @@ exports = module.exports = {
get
};
const domains = require('../domains.js'),
HttpError = require('connect-lastmile').HttpError;
const HttpError = require('connect-lastmile').HttpError,
wellknown = require('../wellknown.js');
function get(req, res, next) {
const host = req.headers['host'];
const location = req.params[0];
domains.get(host, function (error, domain) {
wellknown.get(host, location, function (error, result) {
if (error) return next(new HttpError(404, error.message));
const location = req.params[0];
if (!domain.wellKnown || !(location in domain.wellKnown)) return next(new HttpError(404, 'No custom well-known config'));
res.status(200).send(domain.wellKnown[location]);
res.status(200).set('content-type', result.type).send(result.body);
});
}