diff options
| author | Adam Soltys <[email protected]> | 2022-06-22 21:00:44 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-06-22 21:00:44 -0700 |
| commit | d277cd3e95c1e2c53f49ac965051e77319a0d8d5 (patch) | |
| tree | 0644274c53c1c712ae1d1758344aaebcf1644680 | |
| parent | 268d283d830d8cb8f35415f2f168bae69c8a9b6e (diff) | |
| download | coinos-server-d277cd3e95c1e2c53f49ac965051e77319a0d8d5.tar.gz coinos-server-d277cd3e95c1e2c53f49ac965051e77319a0d8d5.zip | |
update email endpoint
| -rw-r--r-- | index.js | 35 | ||||
| -rw-r--r-- | pnpm-lock.yaml | 2 |
2 files changed, 19 insertions, 18 deletions
@@ -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({ - From: "[email protected]", - To: "[email protected]", - Subject: "Email Signup", - HtmlBody: JSON.stringify(req.body), - TextBody: JSON.stringify(req.body), - MessageStream: "outbound" - }); - } catch(e) { + await client.sendEmail({ + From: "[email protected]", + To: "[email protected]", + 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 |
