-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge advancedTesting end with deployment start
- Loading branch information
1 parent
22a65ab
commit 616b6ac
Showing
51 changed files
with
642 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
ThePhasesOfCraftship/2_best_practice_first/advancedTesting/assignment/end/.eslintignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...ip/2_best_practice_first/advancedTesting/assignment/end/packages/backend/.env.development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
NODE_ENV=development | ||
DATABASE_URL= | ||
NODE_ENV=development |
3 changes: 1 addition & 2 deletions
3
...Craftship/2_best_practice_first/advancedTesting/assignment/end/packages/backend/.env.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
NODE_ENV=test | ||
DATABASE_URL= | ||
NODE_ENV=test |
1 change: 1 addition & 0 deletions
1
...tship/2_best_practice_first/advancedTesting/assignment/end/packages/backend/.eslintignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/dist |
53 changes: 38 additions & 15 deletions
53
.../src/modules/notifications/adapters/transactionalEmailAPI/mailjetTransactionalEmailAPI.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,42 @@ | ||
import { Spy } from "../../../../shared/testDoubles/spy"; | ||
import { | ||
SendMailInput, | ||
TransactionalEmailAPI, | ||
} from "../../ports/transactionalEmailAPI"; | ||
import nodemailer from "nodemailer"; | ||
import { SendMailInput, TransactionalEmailAPI } from "../../ports/transactionalEmailAPI"; | ||
|
||
export class TransactionalEmailAPISpy | ||
extends Spy<TransactionalEmailAPI> | ||
implements TransactionalEmailAPI | ||
{ | ||
constructor() { | ||
super(); | ||
} | ||
|
||
async sendMail(input: SendMailInput): Promise<boolean> { | ||
this.addCall("sendMail", [input]); | ||
return true; | ||
const mailSettings = { | ||
service: process.env.MAIL_SENDER_SERVICE || "gmail", | ||
user: process.env.MAIL_SENDER_EMAIL_ADDRESS, | ||
pass: process.env.MAIL_SENDER_PASSWORD, | ||
}; | ||
|
||
// Create a transporter object using SMTP | ||
const transporter = nodemailer.createTransport({ | ||
service: mailSettings.service, | ||
auth: { | ||
user: mailSettings.user, | ||
pass: mailSettings.pass, | ||
}, | ||
authMethod: "PLAIN", | ||
}); | ||
|
||
export class MailjetTransactionalEmail implements TransactionalEmailAPI { | ||
async sendMail(input: SendMailInput) { | ||
// Email content | ||
const mailOptions = { | ||
from: mailSettings.user, | ||
...input, | ||
}; | ||
|
||
try { | ||
new Promise((resolve, reject) => { | ||
transporter.sendMail(mailOptions, (error, info) => { | ||
if (error) return reject(error); | ||
return resolve(info); | ||
}); | ||
}); | ||
|
||
return true; | ||
} catch (err) { | ||
return false; | ||
} | ||
} | ||
} |
50 changes: 13 additions & 37 deletions
50
...kend/src/modules/notifications/adapters/transactionalEmailAPI/transactionalEmailAPISpy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,20 @@ | ||
import nodemailer from "nodemailer"; | ||
|
||
import { Spy } from "../../../../shared/testDoubles/spy"; | ||
import { | ||
SendMailInput, | ||
TransactionalEmailAPI, | ||
} from "../../ports/transactionalEmailAPI"; | ||
|
||
const mailSettings = { | ||
service: process.env.MAIL_SENDER_SERVICE || "gmail", | ||
user: process.env.MAIL_SENDER_EMAIL_ADDRESS, | ||
pass: process.env.MAIL_SENDER_PASSWORD, | ||
}; | ||
|
||
// Create a transporter object using SMTP | ||
const transporter = nodemailer.createTransport({ | ||
service: mailSettings.service, | ||
auth: { | ||
user: mailSettings.user, | ||
pass: mailSettings.pass, | ||
}, | ||
authMethod: "PLAIN", | ||
}); | ||
|
||
export class MailjetTransactionalEmail implements TransactionalEmailAPI { | ||
async sendMail(input: SendMailInput) { | ||
// Email content | ||
const mailOptions = { | ||
from: mailSettings.user, | ||
...input, | ||
}; | ||
|
||
try { | ||
new Promise((resolve, reject) => { | ||
transporter.sendMail(mailOptions, (error, info) => { | ||
if (error) return reject(error); | ||
return resolve(info); | ||
}); | ||
}); | ||
export class TransactionalEmailAPISpy | ||
extends Spy<TransactionalEmailAPI> | ||
implements TransactionalEmailAPI | ||
{ | ||
constructor() { | ||
super(); | ||
} | ||
|
||
return true; | ||
} catch (err) { | ||
return false; | ||
} | ||
async sendMail(input: SendMailInput): Promise<boolean> { | ||
this.addCall("sendMail", [input]); | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 13 additions & 12 deletions
25
...aftship/2_best_practice_first/advancedTesting/assignment/end/packages/shared/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
{ | ||
"name": "@dddforum/shared", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": {} | ||
} | ||
"name": "@dddforum/shared", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"clean": "rimraf ./dist", | ||
"build": "npm run clean && tsc -b tsconfig.build.json" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
.../2_best_practice_first/advancedTesting/assignment/end/packages/shared/tsconfig.build.json
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...ftship/2_best_practice_first/advancedTesting/assignment/end/packages/shared/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"types": ["node", "jest"], | ||
"types": ["node"] | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.