diff options
| -rw-r--r-- | package.json | 2 | ||||
| -rw-r--r-- | pnpm-lock.yaml | 48 | ||||
| -rw-r--r-- | routes/email.js | 26 |
3 files changed, 47 insertions, 29 deletions
diff --git a/package.json b/package.json index 0ee4096e..edd8fc72 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@fastify/secure-session": "^5.2.0", "@fastify/static": "^6.5.0", "@fastify/websocket": "^7.0.1", + "@sendgrid/mail": "^7.7.0", "bcrypt": "^5.0.0", "bech32": "^2.0.0", "clightning-client": "^0.1.2", @@ -28,7 +29,6 @@ "passport-local": "1.0.0", "pino": "8", "pino-pretty": "^7.0.0", - "postmark": "^3.0.11", "pump": "^3.0.0", "query-string": "^6.13.1", "readable-stream-clone": "^0.0.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9715cbc5..a539adf4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,6 +6,7 @@ specifiers: '@fastify/secure-session': ^5.2.0 '@fastify/static': ^6.5.0 '@fastify/websocket': ^7.0.1 + '@sendgrid/mail': ^7.7.0 bcrypt: ^5.0.0 bech32: ^2.0.0 clightning-client: ^0.1.2 @@ -22,7 +23,6 @@ specifiers: passport-local: 1.0.0 pino: '8' pino-pretty: ^7.0.0 - postmark: ^3.0.11 prettier: ^1.19.1 pump: ^3.0.0 query-string: ^6.13.1 @@ -39,6 +39,7 @@ dependencies: '@fastify/secure-session': 5.2.0 '@fastify/static': 6.5.0 '@fastify/websocket': 7.1.0 + '@sendgrid/mail': 7.7.0 bcrypt: 5.1.0 bech32: 2.0.0 clightning-client: 0.1.4 @@ -55,7 +56,6 @@ dependencies: passport-local: 1.0.0 pino: 8.6.1 pino-pretty: 7.6.1 - postmark: 3.0.14 pump: 3.0.0 query-string: 6.14.1 readable-stream-clone: 0.0.7 @@ -277,6 +277,33 @@ packages: '@redis/client': 1.3.0 dev: false + /@sendgrid/client/7.7.0: + resolution: {integrity: sha512-SxH+y8jeAQSnDavrTD0uGDXYIIkFylCo+eDofVmZLQ0f862nnqbC3Vd1ej6b7Le7lboyzQF6F7Fodv02rYspuA==} + engines: {node: 6.* || 8.* || >=10.*} + dependencies: + '@sendgrid/helpers': 7.7.0 + axios: 0.26.1 + transitivePeerDependencies: + - debug + dev: false + + /@sendgrid/helpers/7.7.0: + resolution: {integrity: sha512-3AsAxfN3GDBcXoZ/y1mzAAbKzTtUZ5+ZrHOmWQ279AuaFXUNCh9bPnRpN504bgveTqoW+11IzPg3I0WVgDINpw==} + engines: {node: '>= 6.0.0'} + dependencies: + deepmerge: 4.3.0 + dev: false + + /@sendgrid/mail/7.7.0: + resolution: {integrity: sha512-5+nApPE9wINBvHSUxwOxkkQqM/IAAaBYoP9hw7WwgDNQPxraruVqHizeTitVtKGiqWCKm2mnjh4XGN3fvFLqaw==} + engines: {node: 6.* || 8.* || >=10.*} + dependencies: + '@sendgrid/client': 7.7.0 + '@sendgrid/helpers': 7.7.0 + transitivePeerDependencies: + - debug + dev: false + /@sindresorhus/is/5.3.0: resolution: {integrity: sha512-CX6t4SYQ37lzxicAqsBtxA3OseeoVrh9cSJ5PFYam0GksYlupRfy1A+Q4aYD3zvcfECLc0zO2u+ZnR2UYKvCrw==} engines: {node: '>=14.16'} @@ -439,8 +466,8 @@ packages: - supports-color dev: false - /axios/0.25.0: - resolution: {integrity: sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==} + /axios/0.26.1: + resolution: {integrity: sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==} dependencies: follow-redirects: 1.15.2 transitivePeerDependencies: @@ -849,6 +876,11 @@ packages: engines: {node: '>=4.0.0'} dev: false + /deepmerge/4.3.0: + resolution: {integrity: sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==} + engines: {node: '>=0.10.0'} + dev: false + /defer-to-connect/2.0.1: resolution: {integrity: sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==} engines: {node: '>=10'} @@ -1972,14 +2004,6 @@ packages: thread-stream: 2.2.0 dev: false - /postmark/3.0.14: - resolution: {integrity: sha512-Bkt6msv+I4Z3Y/jwt2owTNVmahOOyJlS1aQLiWsFAz5fzeJPfEqIUMSPPQTk7lYyJvYnLXQuzhFNG7M8yxqPhA==} - dependencies: - axios: 0.25.0 - transitivePeerDependencies: - - debug - dev: false - /prebuild-install/7.1.1: resolution: {integrity: sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==} engines: {node: '>=10'} diff --git a/routes/email.js b/routes/email.js index 529307e6..05f682af 100644 --- a/routes/email.js +++ b/routes/email.js @@ -1,24 +1,18 @@ import config from "$config"; +import sendgrid from "@sendgrid/mail"; export default { async send({ body }, res) { - try { - let postmark = await import("postmark"); - let client = new postmark.ServerClient(config.postmark); - - await client.sendEmail({ - From: "[email protected]", - To: "[email protected]", - Subject: body.subject || "Email Signup", - HtmlBody: JSON.stringify(body), - TextBody: JSON.stringify(body), - MessageStream: "outbound" - }); + sendgrid.setApiKey(config.sendgrid); + const msg = { + to: "[email protected]", + from: "[email protected]", + subject: body.subject || "Email Signup", + text: JSON.stringify(body), + html: JSON.stringify(body) + }; + await sendgrid.send(msg); res.send({ ok: true }); - } catch (e) { - console.log("problem sending email", e); - res.code(500).send(e.message); - } } }; |
