From 2fb8d264e555910f730315276ce84811a7f7bebf Mon Sep 17 00:00:00 2001 From: rstavchansky Date: Thu, 27 Oct 2022 17:14:48 -0400 Subject: [PATCH 1/9] adding a button to test emails integration --- .emails/welcome/index.html | 6 ++++++ index.html | 8 +++++++- js/script.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .emails/welcome/index.html create mode 100644 js/script.js diff --git a/.emails/welcome/index.html b/.emails/welcome/index.html new file mode 100644 index 0000000..647c680 --- /dev/null +++ b/.emails/welcome/index.html @@ -0,0 +1,6 @@ + + +

Welcome, {{name}}

+

This is a test from your friendly technical writing manager, Rachael Stavchansky. We hope you enjoy our super simple emails!

+ + \ No newline at end of file diff --git a/index.html b/index.html index e2ab5a6..5853a39 100644 --- a/index.html +++ b/index.html @@ -20,7 +20,11 @@ –––––––––––––––––––––––––––––––––––––––––––––––––– --> - + + + +

Hello World

@@ -68,5 +72,7 @@

You can contact this sweet puppy here

+ + \ No newline at end of file diff --git a/js/script.js b/js/script.js new file mode 100644 index 0000000..6f65d94 --- /dev/null +++ b/js/script.js @@ -0,0 +1,29 @@ +sendEmailButton = document.querySelector(".emailTest"); + +var sendEmail = function () { + + import fetch from 'node-fetch' + + await fetch( + `${process.env.URL}/.netlify/functions/emails/welcome`, + { + headers: { + "netlify-emails-secret": process.env.NETLIFY_EMAILS_SECRET, + }, + method: "POST", + body: JSON.stringify({ + from: "no-reply@yourdomain.com", + to: "jane.example@test.com", + cc: "cc@test.com", + bcc: "bcc@test.com", + subject: "Welcome", + parameters: { + products: ["product1", "product2", "product3"], + name: "Jane", + }, + }), + } + ); +} + +sendEmailButton.addEventListener("click", sendEmail); From 9f3b8061354cc85b74d821179a9f490d74f15d3a Mon Sep 17 00:00:00 2001 From: rstavchansky Date: Thu, 27 Oct 2022 17:17:10 -0400 Subject: [PATCH 2/9] =?UTF-8?q?remove=20checklinks=20because=20it=E2=80=99?= =?UTF-8?q?s=20breaking=20things?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- netlify.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/netlify.toml b/netlify.toml index 528831b..6ad1f3a 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,9 +1,3 @@ -[[plugins]] -package = "netlify-plugin-checklinks" - - [plugins.inputs] - checkExternal = true - [[headers]] for = "/protected/*" [headers.values] From 2511f45cfd4013f7d253784bf26a2ad3c9cb9e98 Mon Sep 17 00:00:00 2001 From: rstavchansky Date: Thu, 27 Oct 2022 17:19:21 -0400 Subject: [PATCH 3/9] moved import statement up --- js/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/script.js b/js/script.js index 6f65d94..6e8decc 100644 --- a/js/script.js +++ b/js/script.js @@ -1,9 +1,9 @@ +import fetch from 'node-fetch' + sendEmailButton = document.querySelector(".emailTest"); var sendEmail = function () { - import fetch from 'node-fetch' - await fetch( `${process.env.URL}/.netlify/functions/emails/welcome`, { From b00229564ce2a504db70d01eda3ae1f3a73b481c Mon Sep 17 00:00:00 2001 From: rstavchansky Date: Thu, 27 Oct 2022 17:21:51 -0400 Subject: [PATCH 4/9] tiny change to trigger branch deploy --- js/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/script.js b/js/script.js index 6e8decc..f66fbb9 100644 --- a/js/script.js +++ b/js/script.js @@ -4,7 +4,7 @@ sendEmailButton = document.querySelector(".emailTest"); var sendEmail = function () { - await fetch( +await fetch( `${process.env.URL}/.netlify/functions/emails/welcome`, { headers: { From 46393b91af7d6b25ca12f6304d0de604b140e672 Mon Sep 17 00:00:00 2001 From: rstavchansky Date: Thu, 27 Oct 2022 17:29:24 -0400 Subject: [PATCH 5/9] fix import statement syntax (hopefully) --- js/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/script.js b/js/script.js index f66fbb9..f2315c0 100644 --- a/js/script.js +++ b/js/script.js @@ -1,4 +1,4 @@ -import fetch from 'node-fetch' +import {fetch} from 'node-fetch' sendEmailButton = document.querySelector(".emailTest"); From e5954c15bc8f51f7279d42c70cbfe0b169c48479 Mon Sep 17 00:00:00 2001 From: rstavchansky Date: Thu, 27 Oct 2022 17:32:14 -0400 Subject: [PATCH 6/9] troubleshooting --- js/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/script.js b/js/script.js index f2315c0..bfaed18 100644 --- a/js/script.js +++ b/js/script.js @@ -1,8 +1,8 @@ -import {fetch} from 'node-fetch' +var fetch = require('node-fetch'); sendEmailButton = document.querySelector(".emailTest"); -var sendEmail = function () { +var sendEmail = async function () { await fetch( `${process.env.URL}/.netlify/functions/emails/welcome`, From d6592f23247cb146d13333498cb538c94c8d1a98 Mon Sep 17 00:00:00 2001 From: rstavchansky Date: Thu, 27 Oct 2022 17:38:12 -0400 Subject: [PATCH 7/9] adding package files and such --- .gitignore | 3 +- package-lock.json | 140 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 5 ++ 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore index a013cf3..586c59b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # Local Netlify folder -.netlify \ No newline at end of file +.netlify +/node_modules diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..73ba139 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,140 @@ +{ + "name": "basic-testing", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "node-fetch": "^3.2.10" + } + }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", + "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==", + "engines": { + "node": ">= 12" + } + }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.2.10", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz", + "integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", + "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "engines": { + "node": ">= 8" + } + } + }, + "dependencies": { + "data-uri-to-buffer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", + "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==" + }, + "fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "requires": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + } + }, + "formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "requires": { + "fetch-blob": "^3.1.2" + } + }, + "node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" + }, + "node-fetch": { + "version": "3.2.10", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz", + "integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==", + "requires": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + } + }, + "web-streams-polyfill": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", + "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..7765890 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "node-fetch": "^3.2.10" + } +} From 126a601cef379b766152b41edfd42946a01e34b7 Mon Sep 17 00:00:00 2001 From: rstavchansky Date: Thu, 27 Oct 2022 17:42:00 -0400 Subject: [PATCH 8/9] trying all the things --- js/script.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/script.js b/js/script.js index bfaed18..204e923 100644 --- a/js/script.js +++ b/js/script.js @@ -1,4 +1,6 @@ -var fetch = require('node-fetch'); +//var fetch = require('node-fetch'); + +import fetch from 'node-fetch' sendEmailButton = document.querySelector(".emailTest"); From 982f591c3226ef4951c26001a296c0337fad037b Mon Sep 17 00:00:00 2001 From: rstavchansky Date: Thu, 27 Oct 2022 17:45:08 -0400 Subject: [PATCH 9/9] changing to an ES module instead of commonJS --- index.html | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 5853a39..c11e3af 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,7 @@ - + diff --git a/package.json b/package.json index 7765890..96b14bf 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { "node-fetch": "^3.2.10" - } + }, + "type": "module" }