generated from edenia/full-stack-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
825 additions
and
711 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
host: process.env.HAPI_MAIL_HOST, | ||
port: process.env.HAPI_MAIL_PORT, | ||
user: process.env.HAPI_MAIL_USER, | ||
pass: process.env.HAPI_MAIL_PASSWORD | ||
} |
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,4 +1,5 @@ | ||
const addReferralRoute = require('./add-referral.route') | ||
const sendConfirmationRoute = require('./send-confirmation.route') | ||
const healthzRoute = require('./healthz.route') | ||
|
||
module.exports = [addReferralRoute, healthzRoute] | ||
module.exports = [addReferralRoute, sendConfirmationRoute, healthzRoute] |
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,39 @@ | ||
const Joi = require('joi') | ||
const Boom = require('@hapi/boom') | ||
|
||
const { | ||
mailUtil: { sendConfirmation } | ||
} = require('../utils') | ||
const { | ||
joinRequestService: { findByAccount } | ||
} = require('../services') | ||
|
||
module.exports = { | ||
method: 'POST', | ||
path: '/send-confirmation', | ||
handler: async ({ payload: { input } }) => { | ||
try { | ||
for (const account of input.accounts) { | ||
const { email } = await findByAccount(account) | ||
await sendConfirmation({ | ||
account: account, | ||
to: email, | ||
subject: 'You are ready to share your Proton referral link!' | ||
}) | ||
} | ||
|
||
return { success: true } | ||
} catch (error) { | ||
throw Boom.badRequest(error.message, { code: 'BAD_REQUEST' }) | ||
} | ||
}, | ||
options: { | ||
validate: { | ||
payload: Joi.object({ | ||
input: Joi.object({ | ||
accounts: Joi.array().required() | ||
}).required() | ||
}).options({ stripUnknown: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
const hyperionService = require('./hyperion') | ||
const affiliateService = require('./affiliate.service') | ||
const exchangeService = require('./exchange.service') | ||
const joinRequestService = require('./join-request.service') | ||
const referralsService = require('./referrals.service') | ||
const workerService = require('./worker.service') | ||
|
||
module.exports = { | ||
hyperionService, | ||
affiliateService, | ||
exchangeService, | ||
joinRequestService, | ||
referralsService, | ||
workerService | ||
} |
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,23 @@ | ||
const { hasuraUtil } = require('../utils') | ||
|
||
const findByAccount = async account => { | ||
const query = ` | ||
query ($account: String!) { | ||
join_request(where: {account: {_eq: $account}}) { | ||
id | ||
account | ||
receive_news | ||
created_at | ||
updated_at | ||
} | ||
} | ||
` | ||
const data = await hasuraUtil.instance.request(query, { account }) | ||
|
||
return data.join_request.length ? data.join_request[0] : null | ||
} | ||
|
||
module.exports = { | ||
findByAccount | ||
} |
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,32 @@ | ||
const nodemailer = require('nodemailer') | ||
const { | ||
mailConfig: { host, port, user, pass } | ||
} = require('../config') | ||
const { | ||
mailTemplate: { generateConfirmationMail } | ||
} = require('./templates') | ||
|
||
const sendConfirmation = async ({ account, to, subject }) => { | ||
try { | ||
const transporter = nodemailer.createTransport({ | ||
host, | ||
secure: false, | ||
port, | ||
auth: { user, pass }, | ||
tls: { rejectUnauthorized: false } | ||
}) | ||
|
||
await transporter.sendMail({ | ||
from: `Proton Affiliate <${user}>`, | ||
to, | ||
subject, | ||
html: generateConfirmationMail({ account }) | ||
}) | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
} | ||
|
||
module.exports = { | ||
sendConfirmation | ||
} |
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,3 @@ | ||
module.exports = { | ||
mailTemplate: require('./mail.template') | ||
} |
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,70 @@ | ||
const generateConfirmationMail = ({ account }) => { | ||
return ` | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
<body> | ||
<table style="padding: 0px 16px 0px; margin-left: auto; margin-right: auto;"> | ||
<tr> | ||
<table style="max-width: 640px; margin-left: auto; margin-right: auto;"> | ||
<tr> | ||
<img style="margin: 0px 44px 24px 44px; width: 177.7px; height: 53px; object-fit: scale-down" src="https://earnproton.com/proton.png"/> | ||
</tr> | ||
<tr> | ||
<p align="left" style="margin: 24px 96px; font-family: Arial; font-size: 21px; font-weight: normal; font-stretch: normal; font-style: normal; line-height: normal; letter-spacing: 0.15px; text-align: left; color: #000;"> | ||
Welcome to the Proton On-Chain Referral Program! | ||
</p> | ||
</tr> | ||
<tr> | ||
<p align="left" style="margin: 24px 96px; font-family: Arial; font-size: 16px; font-weight: normal; font-stretch: normal; font-style: normal; line-height: 1.5; letter-spacing: 0.44px; text-align: left; color: #000;"> | ||
Your Proton referral link is now active. You may share the following link with your friends to earn rewards when they complete new account registration and KYC on the Proton network: | ||
</p> | ||
</tr> | ||
<tr> | ||
<p align="center" style="margin: 24px 0 25px;"> | ||
<a href= https://earnproton.com/join/${account}" style="font-family: Arial; font-size: 16px; font-weight: bold; font-stretch: normal; font-style: normal; line-height: 1; letter-spacing: 0.4px; text-align: center; color: #582acb;"> | ||
https://earnproton.com/join/${account} | ||
</a> | ||
</p> | ||
</tr> | ||
<tr> | ||
<p align="left" style="margin: 24px 96px; font-family: Arial; font-size: 16px; font-weight: normal; font-stretch: normal; font-style: normal; line-height: 1.5; letter-spacing: 0.44px; text-align: left; color: #000; overflow-wrap: break-word;"> | ||
To view your referrals and payments, login using your proton wallet at https://earnproton.com. | ||
</p> | ||
</tr> | ||
<tr> | ||
<p align="left" style="margin: 24px 96px 0px; font-family: Arial; font-size: 16px; font-weight: normal; font-stretch: normal; font-style: normal; line-height: 1.5; letter-spacing: 0.44px; text-align: left; color: #000;"> | ||
Best Regards, | ||
</p> | ||
</tr> | ||
<tr> | ||
<p align="left" style="margin: 8px 96px 24px; font-family: Arial; font-size: 16px; font-weight: bold; font-stretch: normal; font-style: normal; line-height: 1.5; letter-spacing: 0.44px; text-align: left; color: #000;"> | ||
The Proton Affiliate Team | ||
<br> | ||
(Edenia, SoftAtom) | ||
</p> | ||
</tr> | ||
</table> | ||
</tr> | ||
<tr> | ||
<table style="height: 157px; margin: 40px 0 0; padding: 22px 96px 15px; background-color: rgba(0, 0, 0, 0.87); margin-left: auto; margin-right: auto;"> | ||
<p align="left" style="flex-grow: 0; margin: 0 0 20px; font-family: Arial; font-size: 14px; font-weight: normal; font-stretch: normal; font-style: normal; line-height: 1.14; letter-spacing: 0.44px; text-align: center; color: #fff;"> | ||
<a href="https://forms.gle/GWHig5ciAvg5fdEH7" style="color: #fff;"> | ||
Apply Here for Funding | ||
</a> | ||
</p> | ||
<p align="left" style="margin: 20px 218px 15px; font-family: Arial; font-size: 12px; font-weight: normal; font-stretch: normal; font-style: normal; line-height: 1.33; letter-spacing: 1.5px; text-align: center; color: #fff;"> | ||
THIS PROJECT WAS FUNDED THROUGH THE PROTON GOVERNANCE COMMITTEE WORKER PROPOSAL SYSTEM | ||
</p> | ||
</table> | ||
</tr> | ||
</table> | ||
</body> | ||
` | ||
} | ||
|
||
module.exports = { | ||
generateConfirmationMail | ||
} |
Oops, something went wrong.