Skip to content

Commit c2c0992

Browse files
authored
Merge pull request #32 from funkenstrahlen/patch-1
Fix syntax errors in mail adapter configuration example & use current mailgun adapter setup
2 parents 48d21b0 + 85a5fff commit c2c0992

File tree

6 files changed

+80
-39
lines changed

6 files changed

+80
-39
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ jobs:
6767
restore-keys: |
6868
${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-
6969
- run: npm ci
70-
- run: npm run lint
7170
- run: npm test
7271
env:
7372
CI: true

CHANGELOG.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,24 @@ Jump directly to a version:
2323
*(none)*
2424

2525
### 🧬 Other Changes
26-
*(none)*
26+
- Fixed demo script and README for `mailgun.js` 3.x which requires `form-data` (Stefan Trauth, Manuel Trezza) [#32](https://github.com/mtrezza/parse-server-api-mail-adapter/pull/32)
2727

2828
# 1.0.7
2929
[Full Changelog](https://github.com/mtrezza/parse-server-api-mail-adapter/compare/1.0.6...1.0.7)
3030

31-
### ⚠️ Breaking Changes
32-
*(none)*
33-
34-
### 🚀 Notable Changes
35-
*(none)*
36-
3731
### 🧬 Other Changes
3832
- Added supported providers to README (Manuel Trezza) [#34](https://github.com/mtrezza/parse-server-api-mail-adapter/pull/34)
3933
- Bump postcss from 8.2.9 to 8.2.15 (dependabot) [#37](https://github.com/mtrezza/parse-server-api-mail-adapter/pull/37)
4034

4135
# 1.0.6
4236
[Full Changelog](https://github.com/mtrezza/parse-server-api-mail-adapter/compare/1.0.5...1.0.6)
4337

44-
### ⚠️ Breaking Changes
45-
*(none)*
46-
47-
### 🚀 Notable Changes
48-
*(none)*
49-
5038
### 🧬 Other Changes
5139
- Fixes failing to send email in Cloud Code without template (Manuel Trezza) [#26](https://github.com/mtrezza/parse-server-api-mail-adapter/pull/26)
5240

5341
# 1.0.5
5442
[Full Changelog](https://github.com/mtrezza/parse-server-api-mail-adapter/compare/1.0.4...1.0.5)
5543

56-
### ⚠️ Breaking Changes
57-
*(none)*
58-
59-
### 🚀 Notable Changes
60-
*(none)*
61-
6244
### 🧬 Other Changes
6345
- Fixes undefined `user` in `localeCallback` when sending email via `Parse.Cloud.sendEmail()` (wlky, Manuel Trezza) [#18](https://github.com/mtrezza/parse-server-api-mail-adapter/pull/18)
6446

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ You can modify the script to use any other API you like or debug-step through th
5858
An example configuration to add the API Mail Adapter to Parse Server could look like this:
5959
6060
```js
61+
const Mailgun = require('mailgun.js');
62+
const formData = require('form-data');
63+
const { ApiPayloadConverter } = require('parse-server-api-mail-adapter');
64+
6165
// Configure mail client
62-
const mailgun = require('mailgun.js');
66+
const mailgun = new Mailgun(formData);
6367
const mailgunClient = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
6468
const mailgunDomain = process.env.MAILGUN_DOMAIN;
6569
@@ -77,24 +81,24 @@ const server = new ParseServer({
7781
// The template used by Parse Server to send an email for password
7882
// reset; this is a reserved template name.
7983
passwordResetEmail: {
80-
subjectPath: './files/password_reset_email_subject.txt'),
81-
textPath: './files/password_reset_email.txt'),
82-
htmlPath: './files/password_reset_email.html')
84+
subjectPath: './files/password_reset_email_subject.txt',
85+
textPath: './files/password_reset_email.txt',
86+
htmlPath: './files/password_reset_email.html'
8387
},
8488
// The template used by Parse Server to send an email for email
8589
// address verification; this is a reserved template name.
8690
verificationEmail: {
87-
subjectPath: './files/verification_email_subject.txt'),
88-
textPath: './files/verification_email.txt'),
89-
htmlPath: './files/verification_email.html')
91+
subjectPath: './files/verification_email_subject.txt',
92+
textPath: './files/verification_email.txt',
93+
htmlPath: './files/verification_email.html'
9094
},
9195
// A custom email template that can be used when sending emails
9296
// from Cloud Code; the template name can be chosen freely; it
9397
// is possible to add various custom templates.
9498
customEmail: {
95-
subjectPath: './files/custom_email_subject.txt'),
96-
textPath: './files/custom_email.txt'),
97-
htmlPath: './files/custom_email.html'),
99+
subjectPath: './files/custom_email_subject.txt',
100+
textPath: './files/custom_email.txt',
101+
htmlPath: './files/custom_email.html',
98102
// Placeholders are filled into the template file contents.
99103
// For example, the placeholder `{{appName}}` in the email
100104
// will be replaced the value defined here.
@@ -144,9 +148,9 @@ Emails are composed using templates. A template defines the paths to its content
144148
```js
145149
templates: {
146150
exampleTemplate: {
147-
subjectPath: './files/custom_email_subject.txt'),
148-
textPath: './files/custom_email.txt'),
149-
htmlPath: './files/custom_email.html'),
151+
subjectPath: './files/custom_email_subject.txt',
152+
textPath: './files/custom_email.txt',
153+
htmlPath: './files/custom_email.html',
150154
}
151155
},
152156
```
@@ -300,4 +304,4 @@ const server = new ParseServer({
300304
# Need help?
301305

302306
- Ask on StackOverflow using the [parse-server](https://stackoverflow.com/questions/tagged/parse-server) tag.
303-
- Search through existing [issues](https://github.com/mtrezza/parse-server-api-mail-adapter/issues) or open a new issue.
307+
- Search through existing [issues](https://github.com/mtrezza/parse-server-api-mail-adapter/issues) or open a new issue.

demo/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
'use strict';
2+
13
/**
24
* ==============================================================
35
* Demo script to send an email using the Mailgun API.
46
* ==============================================================
57
* Instructions:
68
*
7-
* 1. Create a file `mailgun.json` in the root directory with the
8-
* following keys to configure the test script:
9+
* 1. Create a file `mailgun.json` in the directory of this demo
10+
* script with the following keys to configure the demo script:
11+
*
912
* ```
1013
* {
1114
* key: "xxx", // The Mailgun API key.
@@ -16,13 +19,14 @@
1619
* }
1720
* ```
1821
*
19-
* 2. Run this script with `node ./demo` to send the email.
22+
* 2. Run this script with `node ./demo` to send an email. 🤞
2023
* ==============================================================
2124
*/
2225

2326
const ApiMailAdapter = require('../src/ApiMailAdapter');
2427
const ApiPayloadConverter = require('../src/ApiPayloadConverter');
25-
const mailgun = require('mailgun.js');
28+
const formData = require("form-data");
29+
const Mailgun = require('mailgun.js');
2630
const path = require('path');
2731

2832
const {
@@ -32,7 +36,11 @@ const {
3236
recipient
3337
} = require('./mailgun.json');
3438

35-
const mailgunClient = mailgun.client({ username: 'api', key: key });
39+
// Declare mail client
40+
const mailgun = new Mailgun(formData);
41+
const mailgunClient = mailgun.client({ username: "api", key });
42+
43+
// Configure mail client
3644
const filePath = (file) => path.resolve(__dirname, '../spec/templates/', file);
3745
const config = {
3846
sender: sender,

package-lock.json

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"codecov": "3.8.1",
4040
"eslint": "7.22.0",
4141
"eslint-plugin-flowtype": "5.4.0",
42+
"form-data": "4.0.0",
4243
"jasmine": "3.6.4",
4344
"madge": "4.0.2",
4445
"mailgun.js": "3.2.1",

0 commit comments

Comments
 (0)