Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification setup #6

Merged
merged 12 commits into from
Feb 8, 2020
Merged
5 changes: 5 additions & 0 deletions scripts/install
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ if [[ $# -eq 0 ]]; then
install_kubernetes
source ./lib/install_kafka.sh
install_kafka
source ./lib/install_node.sh
install_node_all
source ./lib/install_opencv.sh
install_opencv
else
Expand All @@ -24,6 +26,9 @@ else
source ./lib/install_kafka.sh
install_kafka
;;
node)
source ./lib/install_node.sh
install_node_all
chc5 marked this conversation as resolved.
Show resolved Hide resolved
opencv)
source ./lib/install_opencv.sh
install_opencv
Expand Down
21 changes: 21 additions & 0 deletions scripts/lib/install_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Install Node and necessary frameworks/packages

# Install Node.js on Arch Linux
install_node() {
command -v node >/dev/null 2>&1 || {
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
source ~/.nvm.sh
chc5 marked this conversation as resolved.
Show resolved Hide resolved
nvm install node
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually install the specific version of node like nvm install 13.8 and then nvm use 13.8. It's better to install the specific version of node to remove any bugs associated with different node versions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I think 12.15.0 would be suitable for this as it's the latest stable version.

};
}

# Install dependencies for notification folder
init_notif() {
cd ../../src/notifications && sudo npm install
chc5 marked this conversation as resolved.
Show resolved Hide resolved
}

#Install node and initializes configuration for Node related apps
install_node_all() {
install_node;
init_notif;
}
2 changes: 2 additions & 0 deletions src/notifications/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
keys.env
34 changes: 34 additions & 0 deletions src/notifications/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const nodemailer = require('nodemailer');
require('dotenv').config({ path: './keys.env'});

let transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD
}
});


const message = {
from: 'Meowl Notification Service', // Sender address
to: '[email protected]', // List of recipients
subject: 'This is a test email', // Subject line
text: 'If you receive this message, nodemailer works!' // Plain text body
};

transporter.verify((error, success) => {
if (error) {
console.log(error);
} else {
console.log('Server is ready to take messages');
}
});

transporter.sendMail(message, function(err, info) {
if (err) {
console.log(err)
} else {
console.log(info);
}
});
18 changes: 18 additions & 0 deletions src/notifications/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/notifications/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "notifications",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "^8.2.0",
"nodemailer": "^6.4.2"
}
}