This commit is contained in:
Leandro Facchinetti 2021-03-10 11:35:48 +00:00
parent 319838f7b3
commit 5df7656559
3 changed files with 36 additions and 19 deletions

View File

@ -1,6 +1,6 @@
module.exports = (require) => {
const killTheNewsletter = require(".").default;
const { webApplication, emailApplication } = killTheNewsletter();
const { webApplication, emailApplication } = killTheNewsletter(__dirname);
webApplication.listen(new URL(webApplication.get("url")).port, () => {
console.log(`Web server started at ${webApplication.get("url")}`);

View File

@ -12,7 +12,7 @@
viewBox="0 0 46.574733 14.012067"
version="1.1"
id="svg8"
inkscape:version="1.0 (4035a4f, 2020-05-01)"
inkscape:version="1.0.2 (e86c8708, 2021-01-15)"
sodipodi:docname="logo.svg">
<defs
id="defs2" />
@ -32,10 +32,10 @@
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1440"
inkscape:window-height="855"
inkscape:window-width="1920"
inkscape:window-height="1027"
inkscape:window-x="0"
inkscape:window-y="23"
inkscape:window-y="25"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
@ -74,14 +74,9 @@
d="m 155.09386,116.25295 h 3.11645 l -3e-5,1.52841 c 0,0.13237 0.0686,0.25541 0.18123,0.32503 0.11264,0.0697 0.25331,0.076 0.37175,0.0167 l 6.11361,-3.05679 c 0.12946,-0.0647 0.21121,-0.19707 0.21123,-0.34176 -1e-5,-0.14475 -0.0818,-0.27706 -0.21123,-0.34176 l -6.11363,-3.05682 c -0.11847,-0.0592 -0.25912,-0.0529 -0.37176,0.0167 -0.11269,0.0695 -0.18126,0.19257 -0.18122,0.32503 l -2e-5,1.52841 -3.11642,2e-5 c -0.1055,0 -0.20105,0.0428 -0.27019,0.1119 -0.0691,0.0692 -0.11192,0.16467 -0.11188,0.27017 l -1e-5,2.29262 c 0,0.21104 0.17106,0.38211 0.38211,0.38209 z m 0.3821,-2.29261 3.11642,-1e-5 c 0.21101,1e-5 0.38211,-0.17109 0.3821,-0.3821 v -1.29225 l 4.87712,2.43856 -4.87712,2.43855 v -1.29224 c 2e-5,-0.21083 -0.17108,-0.38212 -0.3821,-0.3821 h -3.11643 z"
id="path1447"
style="stroke-width:0.264583" />
<rect
style="fill:none;stroke:#000000;stroke-width:1.11125;stroke-miterlimit:4;stroke-dasharray:none;stop-color:#000000"
<path
id="rect35"
width="12.900817"
height="12.900817"
x="167.28108"
y="107.67662"
rx="1.3229166"
ry="1.3229166" />
style="fill:none;stroke:#000000;stroke-width:1.11125;stroke-miterlimit:4;stroke-dasharray:none;stop-color:#000000"
d="m 168.604,107.67662 h 10.25498 c 0.7329,0 1.32292,0.59002 1.32292,1.32292 v 10.25498 c 0,0.7329 -0.59002,1.32292 -1.32292,1.32292 H 168.604 c -0.7329,0 -1.32292,-0.59002 -1.32292,-1.32292 v -10.25498 c 0,-0.7329 0.59002,-1.32292 1.32292,-1.32292 z" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -7,6 +7,8 @@ import fs from "fs-extra";
import cryptoRandomString from "crypto-random-string";
import { html, HTML } from "@leafac/html";
import { css, process as processCSS } from "@leafac/css";
import { sql, Database } from "@leafac/sqlite";
import databaseMigrate from "@leafac/sqlite-migration";
const VERSION = require("../package.json").version;
@ -20,6 +22,31 @@ export default function killTheNewsletter(
webApplication.set("email host", "localhost");
webApplication.set("administrator", "mailto:kill-the-newsletter@leafac.com");
const database = new Database(
path.join(rootDirectory, "kill-the-newsletter.db")
);
databaseMigrate(database, [
sql`
CREATE TABLE "feeds" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"createdAt" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
"reference" TEXT NOT NULL UNIQUE,
"title" TEXT NOT NULL
);
CREATE TABLE "entries" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"createdAt" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
"reference" TEXT NOT NULL UNIQUE,
"feed" INTEGER NOT NULL REFERENCES "feeds",
"title" TEXT NOT NULL,
"author" TEXT NOT NULL,
"content" TEXT NOT NULL
);
`,
]);
webApplication.use(express.static(path.join(__dirname, "../public")));
webApplication.use(express.urlencoded({ extended: true }));
@ -153,10 +180,6 @@ export default function killTheNewsletter(
path {
fill: #ffffffd4;
}
rect {
stroke: #ffffffd4;
}
}
`}"
>
@ -189,7 +212,7 @@ export default function killTheNewsletter(
<input
type="text"
name="name"
placeholder="Newsletter Name…"
placeholder="Newsletter name…"
maxlength="500"
required
autocomplete="off"
@ -222,7 +245,6 @@ export const webServer = express()
res.header("X-Robots-Tag", "noindex");
next();
})
.get("/", (req, res) => res.send(layout(newInbox())))
.post("/", async (req, res, next) => {
try {
const { name } = req.body;