This commit is contained in:
parent
534d43bd0b
commit
bcd9a8efce
|
@ -911,6 +911,15 @@
|
|||
"integrity": "sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/xml2js": {
|
||||
"version": "0.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/xml2js/-/xml2js-0.4.5.tgz",
|
||||
"integrity": "sha512-yohU3zMn0fkhlape1nxXG2bLEGZRc1FeqF80RoHaYXJN7uibaauXfhzhOJr1Xh36sn+/tx21QAOf07b/xYVk1w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/yargs": {
|
||||
"version": "15.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.4.tgz",
|
||||
|
@ -1841,10 +1850,19 @@
|
|||
}
|
||||
},
|
||||
"crypto-random-string": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz",
|
||||
"integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=",
|
||||
"dev": true
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-3.2.0.tgz",
|
||||
"integrity": "sha512-8vPu5bsKaq2uKRy3OL7h1Oo7RayAWB8sYexLKAqvCXVib8SxgbmoF1IN4QMKjBv8uI8mp5gPPMbiRah25GMrVQ==",
|
||||
"requires": {
|
||||
"type-fest": "^0.8.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"type-fest": {
|
||||
"version": "0.8.1",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
|
||||
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"cssom": {
|
||||
"version": "0.4.4",
|
||||
|
@ -6621,6 +6639,14 @@
|
|||
"dev": true,
|
||||
"requires": {
|
||||
"crypto-random-string": "^1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"crypto-random-string": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz",
|
||||
"integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"unpipe": {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"develop": "concurrently \"tsc --watch\" \"nodemon lib/server.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"crypto-random-string": "^3.2.0",
|
||||
"express": "^4.17.1",
|
||||
"react": "^16.13.0",
|
||||
"react-dom": "^16.13.0",
|
||||
|
@ -12,8 +13,10 @@
|
|||
"devDependencies": {
|
||||
"@types/express": "^4.17.3",
|
||||
"@types/jest": "^25.1.4",
|
||||
"@types/node": "^13.9.1",
|
||||
"@types/react": "^16.9.23",
|
||||
"@types/react-dom": "^16.9.5",
|
||||
"@types/xml2js": "^0.4.5",
|
||||
"concurrently": "^5.1.0",
|
||||
"jest": "^25.1.0",
|
||||
"nodemon": "^2.0.2",
|
||||
|
|
|
@ -80,3 +80,38 @@ export class Form extends React.Component {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class Created extends React.Component<{ name: string; token: string }> {
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
<h1>“{this.props.name}” Inbox Created</h1>
|
||||
<p>
|
||||
Sign up for the newsletter with
|
||||
<br />
|
||||
<code>{this.props.token}@kill-the-newsletter.com</code>
|
||||
</p>
|
||||
<p>
|
||||
Subscribe to the Atom feed at
|
||||
<br />
|
||||
<code>
|
||||
https://www.kill-the-newsletter.com/feeds/{this.props.token}.xml
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
Don’t share these addresses.
|
||||
<br />
|
||||
They contain a security token that other people could use
|
||||
<br />
|
||||
to send you spam and to control your newsletter subscriptions.
|
||||
</p>
|
||||
<p>Enjoy your readings!</p>
|
||||
<p>
|
||||
<a href="https://www.kill-the-newsletter.com">
|
||||
<strong>Create Another Inbox</strong>
|
||||
</a>
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import express from "express";
|
||||
import React from "react";
|
||||
import ReactDOMServer from "react-dom/server";
|
||||
import { Layout, Form } from "./components";
|
||||
import { Layout, Form, Created } from "./components";
|
||||
import fs from "fs";
|
||||
import cryptoRandomString from "crypto-random-string";
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(express.static("static"));
|
||||
app.use(express.urlencoded());
|
||||
|
||||
app.get("/", (req, res) =>
|
||||
res.send(
|
||||
|
@ -17,6 +20,22 @@ app.get("/", (req, res) =>
|
|||
)
|
||||
);
|
||||
|
||||
app.post("/", (req, res) => {
|
||||
res.send(
|
||||
render(
|
||||
<Layout>
|
||||
<Created
|
||||
name={req.body.name}
|
||||
token={cryptoRandomString({
|
||||
length: 20,
|
||||
characters: "1234567890qwertyuiopasdfghjklzxcvbnm"
|
||||
})}
|
||||
></Created>
|
||||
</Layout>
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
app.listen(8000);
|
||||
|
||||
function render(component: React.ReactElement): string {
|
||||
|
|
Loading…
Reference in New Issue