2021-03-14 00:36:06 +01:00
|
|
|
module.exports = async (require) => {
|
|
|
|
const path = require("path");
|
|
|
|
const express = require("express");
|
|
|
|
const AutoEncrypt = require("@small-tech/auto-encrypt");
|
2021-03-14 00:47:28 +01:00
|
|
|
const killTheNewsletter = require(".").default;
|
2021-03-14 00:36:06 +01:00
|
|
|
|
2021-03-14 00:47:28 +01:00
|
|
|
const { webApplication, emailApplication } = killTheNewsletter(
|
|
|
|
path.join(__dirname, "data")
|
|
|
|
);
|
2021-03-14 00:36:06 +01:00
|
|
|
|
2021-03-14 00:47:28 +01:00
|
|
|
webApplication.set("url", "https://kill-the-newsletter.com");
|
|
|
|
webApplication.set("email", "smtp://kill-the-newsletter.com:25");
|
|
|
|
webApplication.set("administrator", "mailto:kill-the-newsletter@leafac.com");
|
2021-03-14 00:36:06 +01:00
|
|
|
|
|
|
|
const reverseProxy = express();
|
|
|
|
|
|
|
|
reverseProxy.use((req, res, next) => {
|
|
|
|
if (req.hostname !== new URL(app.get("url")).hostname)
|
|
|
|
return res.redirect(`${app.get("url")}${req.originalUrl}`);
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
|
|
|
|
AutoEncrypt.https
|
|
|
|
.createServer(
|
|
|
|
{
|
2021-03-14 00:47:28 +01:00
|
|
|
domains: ["kill-the-newsletter.com", "www.kill-the-newsletter.com"],
|
2021-03-14 00:36:06 +01:00
|
|
|
settingsPath: path.join(__dirname, "data/keys/tls"),
|
|
|
|
},
|
|
|
|
reverseProxy
|
|
|
|
)
|
|
|
|
.listen(443);
|
|
|
|
};
|