aboutsummaryrefslogtreecommitdiffstats
path: root/index.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-06-22 21:00:44 -0700
committerAdam Soltys <[email protected]>2022-06-22 21:00:44 -0700
commitd277cd3e95c1e2c53f49ac965051e77319a0d8d5 (patch)
tree0644274c53c1c712ae1d1758344aaebcf1644680 /index.js
parent268d283d830d8cb8f35415f2f168bae69c8a9b6e (diff)
downloadcoinos-server-d277cd3e95c1e2c53f49ac965051e77319a0d8d5.tar.gz
coinos-server-d277cd3e95c1e2c53f49ac965051e77319a0d8d5.zip
update email endpoint
Diffstat (limited to 'index.js')
-rw-r--r--index.js35
1 files changed, 18 insertions, 17 deletions
diff --git a/index.js b/index.js
index 3e0cd436..1c1b171c 100644
--- a/index.js
+++ b/index.js
@@ -108,30 +108,31 @@ app.post("/email", async (req, res) => {
try {
let file = persist("data/emails.json");
file.emails = [...file.emails, req.body];
- res.send({ ok: true });
try {
- // Require:
- var postmark = require("postmark");
+ // Require:
+ var postmark = require("postmark");
- // Send an email:
- var client = new postmark.ServerClient(
- config.postmark
- );
+ // Send an email:
+ var client = new postmark.ServerClient(config.postmark);
- client.sendEmail({
- Subject: "Email Signup",
- HtmlBody: JSON.stringify(req.body),
- TextBody: JSON.stringify(req.body),
- MessageStream: "outbound"
- });
- } catch(e) {
+ await client.sendEmail({
+ Subject: req.body.subject || "Email Signup",
+ HtmlBody: JSON.stringify(req.body),
+ TextBody: JSON.stringify(req.body),
+ MessageStream: "outbound"
+ });
+
+ res.send({ ok: true });
+ } catch (e) {
console.log("problem sending email", e);
- }
+ res.code(500).send(e.message);
+ }
} catch (e) {
console.log(e);
+ res.code(500).send(e.message);
}
});