mailserver: add queue routes
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
exports = module.exports = {
|
||||
proxy,
|
||||
restart,
|
||||
queueProxy,
|
||||
|
||||
setLocation,
|
||||
getLocation
|
||||
@@ -26,8 +27,8 @@ async function restart(req, res, next) {
|
||||
next();
|
||||
}
|
||||
|
||||
async function proxy(req, res, next) {
|
||||
let parsedUrl = url.parse(req.url, true /* parseQueryString */);
|
||||
async function proxyToMailContainer(port, req, res, next) {
|
||||
const parsedUrl = url.parse(req.url, true /* parseQueryString */);
|
||||
const pathname = req.path.split('/').pop();
|
||||
|
||||
// do not proxy protected values
|
||||
@@ -41,7 +42,7 @@ async function proxy(req, res, next) {
|
||||
parsedUrl.query['access_token'] = addonDetails.token;
|
||||
req.url = url.format({ pathname: pathname, query: parsedUrl.query });
|
||||
|
||||
const proxyOptions = url.parse(`http://${addonDetails.ip}:3000`);
|
||||
const proxyOptions = url.parse(`http://${addonDetails.ip}:${port}`);
|
||||
const mailserverProxy = middleware.proxy(proxyOptions);
|
||||
|
||||
req.clearTimeout(); // TODO: add timeout to mail server proxy logic instead of this
|
||||
@@ -55,6 +56,14 @@ async function proxy(req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
async function proxy(req, res, next) {
|
||||
proxyToMailContainer(3000, req, res, next);
|
||||
}
|
||||
|
||||
async function queueProxy(req, res, next) {
|
||||
proxyToMailContainer(6000, req, res, next);
|
||||
}
|
||||
|
||||
async function getLocation(req, res, next) {
|
||||
const [error, result] = await safe(mail.getLocation());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
Reference in New Issue
Block a user