-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added security checks and enhanced barter init and resp logic
- Loading branch information
1 parent
99147c9
commit fa48eac
Showing
3 changed files
with
105 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// custom mail options based on the params passed for different use cases | ||
// separation of concerns | ||
|
||
function mailOptions({ from, to, subject, text }) { | ||
const defaultFrom = 'noreply@splitbhai.com'; | ||
if (!from || typeof from !== 'string') { | ||
from = defaultFrom; | ||
} | ||
if (!to || !to.email || typeof to.email !== 'string') { | ||
throw new Error('Invalid recipient email address.'); | ||
} | ||
|
||
if (!subject || typeof subject !== 'string') { | ||
throw new Error('Invalid subject.'); | ||
} | ||
if (!text || typeof text !== 'string') { | ||
throw new Error('Invalid email body.'); | ||
} | ||
|
||
// Safe email data to be returned | ||
return { | ||
from: from, | ||
to: to.email, | ||
subject: subject, | ||
text: text, | ||
}; | ||
} | ||
|
||
module.exports = mailOptions; |