-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
98dde7f
commit 213d383
Showing
10 changed files
with
114 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
**/node_modules | ||
public-frontend/ | ||
**/*.config.* | ||
src/dev/clearCache.js | ||
src/dev/* | ||
src/frontend/spotifyWebSDK/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,47 @@ | ||
import sgMail from "@sendgrid/mail"; | ||
import { ClientResponse } from "@sendgrid/client/src/response"; | ||
import { CONFIG, print } from "../util/util"; | ||
|
||
export interface Mail{ | ||
email: string, | ||
subject: string, | ||
message: string, | ||
htmlEnable?: boolean | ||
} | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
export interface MailService{ | ||
send: (mail: Mail) => Promise<[ClientResponse, {}]>; | ||
fromEmail: string; | ||
} | ||
|
||
const MailServiceObj = new Promise<MailService>((resolve, reject) => { | ||
if (process.env.SENDGRID_API_KEY) { | ||
sgMail.setApiKey(process.env.SENDGRID_API_KEY); | ||
resolve({ | ||
fromEmail: CONFIG.fromEmail, | ||
send: ({ email, subject, message, htmlEnable = false }) => { | ||
return new Promise<[ClientResponse, {}]>((resolve, reject) => { | ||
const msg = { | ||
to: email, | ||
from: CONFIG.fromEmail, | ||
subject: subject, | ||
text: htmlEnable ? " " : message, | ||
html: htmlEnable ? message : " " | ||
}; | ||
sgMail.send(msg).then(resolve).catch(reject); | ||
}); | ||
} | ||
}); | ||
} else { | ||
reject(new Error("SENDGRID_API_KEY not set!")); | ||
} | ||
}); | ||
/* eslint-enable @typescript-eslint/ban-types */ | ||
|
||
export default MailServiceObj; | ||
|
||
export function fireAndForgetMail (mail: Mail): void { | ||
MailServiceObj.then(({ send }) => { | ||
send(mail).catch(print); | ||
}).catch(print); | ||
} |
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,24 @@ | ||
import { Mail } from "./email"; | ||
|
||
const welcomeEmail = ` | ||
Welcome to <strong>GCS Radio</strong> | ||
<br /><br /> | ||
A project built entirely by me, <a href="https://bw.codexwilkes.com/portfolio/">Brennan</a>! | ||
<br /><br /> | ||
To get started, go to the <a href="https://gcs-radio.494913.xyz/">dashboard</a>. | ||
<br /><br /> | ||
GCS Radio is entirely open-source, so if you want to deploy it yourself, contribute ideas, report bugs, or just check out the code, feel free to check out the <a href="https://gitlab.com/brennanwilkes/gcs-radio">GIT repo</a>. | ||
<br /><br /> | ||
Thanks for checking GCS Radio out! | ||
<br /><br /> | ||
Brennan | ||
`; | ||
|
||
export default function (email: string): Mail { | ||
return { | ||
email: email, | ||
subject: `Welcome to GCS Radio`, | ||
message: welcomeEmail, | ||
htmlEnable: 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 |
---|---|---|
|
@@ -14,7 +14,8 @@ export const CONFIG = { | |
}, | ||
spotifyOauth2Credentials: { | ||
scope: ["user-read-private", "user-read-email", "streaming"] | ||
} | ||
}, | ||
fromEmail: "GCS Radio <[email protected]>" | ||
}; | ||
|
||
/** | ||
|
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,2 @@ | ||
use gcs-radio | ||
db.users.drop() |