diff --git a/src/index.tsx b/src/index.tsx
index b479899..9f701ed 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -22,13 +22,14 @@ const webApp = express()
)
)
.post("/", (req, res) => {
- const inbox: Inbox = { name: req.body.name, token: newToken() };
- fs.writeFileSync(feedPath(inbox.token), renderXML(Feed(inbox)));
+ const name = req.body.name;
+ const token = newToken();
+ fs.writeFileSync(feedPath(token), renderXML(Feed({ name, token })));
res.send(
renderHTML(
“{name}” Inbox Created
-
@@ -213,8 +209,7 @@ function Created({ inbox: { name, token } }: { inbox: Inbox }) {
);
}
-function Feed(inbox: Inbox) {
- const { name, token } = inbox;
+function Feed({ name, token }: { name: string; token: string }) {
return {
feed: {
$: { xmlns: "http://www.w3.org/2005/Atom" },
@@ -242,7 +237,7 @@ function Feed(inbox: Inbox) {
title: `“${name}” Inbox Created`,
author: "Kill the Newsletter!",
content: ReactDOMServer.renderToStaticMarkup(
-
HTML content
" }); - const feed = readFeed(token); + const feed = await readFeed(token); expect(feed).toMatch("publisher@example.com"); expect(feed).toMatch("New Message"); expect(feed).toMatch("HTML content"); @@ -44,7 +38,7 @@ describe("receive email", () => { subject: "New Message", text: "TEXT content" }); - const feed = readFeed(token); + const feed = await readFeed(token); expect(feed).toMatch("TEXT content"); }); @@ -57,7 +51,7 @@ describe("receive email", () => { subject: "New Message", text: `REPETITION ${repetition} `.repeat(10_000) }); - const feed = readFeed(token); + const feed = await readFeed(token); expect(feed).toMatch("REPETITION 3"); expect(feed).not.toMatch("REPETITION 0"); }, 10_000); @@ -80,6 +74,6 @@ async function createFeed(): Promise