diff --git a/src/index.ts b/src/index.ts index ee5220b..b34e20c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -65,6 +65,28 @@ export default function killTheNewsletter( name="viewport" content="width=device-width, initial-scale=1.0" /> + + + + + Kill the Newsletter! { - try { - const { name } = req.body; - const identifier = createIdentifier(); - const renderedCreated = created(identifier); - await writeFileAtomic( - feedFilePath(identifier), - feed( - identifier, - X(name), - entry( - identifier, - createIdentifier(), - `“${X(name)}” Inbox Created`, - "Kill the Newsletter!", - X(renderedCreated) - ) - ) - ); - res.send( - layout(html` -

“${H(name)}” Inbox Created

- ${renderedCreated} - `) - ); - } catch (error) { - console.error(error); - next(error); - } - }) .get( alternatePath(":feedIdentifier", ":entryIdentifier"), async (req, res, next) => { @@ -363,7 +355,6 @@ export const webServer = express() } } ) - .listen(WEB_PORT, () => console.log(`Server started: ${webApplication.get("url")}`)); export const emailServer = new SMTPServer({ disabledCommands: ["AUTH", "STARTTLS"], @@ -432,67 +423,6 @@ export const emailServer = new SMTPServer({ }, }).listen(EMAIL_PORT); -function layout(content: string): string { - return html` - - - - - - Kill the Newsletter! - - - - - - - - -
${content}
- - - - - `.trim(); -} - -function created(identifier: string): string { - return html` -

- Sign up for the newsletter with
${feedEmail(identifier)} -

-

- Subscribe to the Atom feed at
${feedURL(identifier)} -

-

- Don’t share these addresses.
They contain an identifier that other - people could use
to send you spam and to control your newsletter - subscriptions. -

-

Enjoy your readings!

-

- Create Another Inbox -

- `.trim(); -} - function feed(identifier: string, name: string, initialEntry: string): string { return html` @@ -539,29 +469,6 @@ function entry( `.trim(); } -function createIdentifier(): string { - return cryptoRandomString({ - length: 16, - characters: "1234567890qwertyuiopasdfghjklzxcvbnm", - }); -} - -function now(): string { - return new Date().toISOString(); -} - -function feedFilePath(identifier: string): string { - return `static/feeds/${identifier}.xml`; -} - -function feedURL(identifier: string): string { - return `${webApplication.get("url")}/feeds/${identifier}.xml`; -} - -function feedEmail(identifier: string): string { - return `${identifier}@${EMAIL_DOMAIN}`; -} - function alternatePath( feedIdentifier: string, entryIdentifier: string @@ -576,12 +483,4 @@ function alternateURL(feedIdentifier: string, entryIdentifier: string): string { function urn(identifier: string): string { return `urn:kill-the-newsletter:${identifier}`; } - -function X(string: string): string { - return entities.encodeXML(sanitizeXMLString.sanitize(string)); -} - -function H(string: string): string { - return entities.encodeHTML(sanitizeXMLString.sanitize(string)); -} */