aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.js35
-rw-r--r--pnpm-lock.yaml2
2 files changed, 19 insertions, 18 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);
}
});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index bd05d57d..aa7ab550 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1049,7 +1049,7 @@ packages:
dev: false
/bs58/4.0.1:
- resolution: {integrity: sha1-vhYedsNU9veIrkBx9j806MTwpCo=}
+ resolution: {integrity: sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==}
dependencies:
base-x: 3.0.8
dev: false