-
Notifications
You must be signed in to change notification settings - Fork 11
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
8 changed files
with
2,277 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
# editorconfig-tools is unable to ignore longs strings or urls | ||
max_line_length = null |
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 @@ | ||
{ | ||
"extends": [ | ||
"airbnb-base" | ||
], | ||
"env": { | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"comma-dangle": [ | ||
"error", | ||
{ | ||
"arrays": "always-multiline", | ||
"objects": "always-multiline", | ||
"imports": "always-multiline", | ||
"exports": "always-multiline", | ||
"functions": "ignore" | ||
} | ||
] | ||
} | ||
} |
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 |
---|---|---|
|
@@ -57,3 +57,5 @@ typings/ | |
# dotenv environment variables file | ||
.env | ||
|
||
# App-spesific | ||
config.js |
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,36 @@ | ||
module.exports = { | ||
interval: 6000, // Feed check interval | ||
notifications: { | ||
pushbullet: { | ||
enabled: false, | ||
accessToken: 'XXX', | ||
}, | ||
smtp: { | ||
enabled: true, | ||
config: { // Nodemailer configuration | ||
host: 'smtp.service.com', | ||
port: 465, | ||
secure: true, | ||
auth: { | ||
user: 'smtp@user.com', | ||
pass: 'password', | ||
}, | ||
}, | ||
// tls: true, | ||
mailOptions: { | ||
from: '"AlertHub" <smtp@user.com>', // from field, can be pure e-mail or "Name" <e-mail> format | ||
to: 'your@email.com', // Your Email, can add more e-mails by commas | ||
subjectPrefix: 'New Release', // Subject prefix | ||
}, | ||
}, | ||
}, | ||
repositories: [ | ||
'ardakilic/alerthub', // can be resolved as https://github.com/ardakilic/alerthub | ||
'expressjs/express', | ||
'Unitech/pm2', | ||
'facebook/react', | ||
], | ||
extras: [ | ||
// direct rss links from other sources if you want to watch in this tool | ||
], | ||
}; |
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,55 @@ | ||
// First, let's require the libraries | ||
const config = require('./config'); | ||
const utils = require('./utils'); | ||
const RssFeedEmitter = require('rss-feed-emitter'); | ||
|
||
// RSS Feed emitter to watch and parse feed | ||
const feeder = new RssFeedEmitter(); | ||
|
||
const bootTime = new Date(); | ||
console.log(`Application booted at ${bootTime}`); | ||
|
||
// First, let's add all the feed lists | ||
config.repositories.forEach((feed) => { | ||
feeder.add({ | ||
url: `https://github.com/${feed}/releases.atom`, | ||
refresh: config.interval, | ||
}); | ||
}); | ||
|
||
config.extras.forEach((feed) => { | ||
feeder.add({ | ||
url: feed, | ||
refresh: config.interval, | ||
}); | ||
}); | ||
|
||
|
||
feeder.add({ | ||
url: 'https://lorem-rss.herokuapp.com/feed?unit=second&interval=10', | ||
refresh: 2000, | ||
}); | ||
|
||
feeder.on('new-item', async (item) => { | ||
console.log(`New item! ${item.title}!`); | ||
|
||
// console.log(item); | ||
// Past (Current) feeds are also pushed to feed on initial boot | ||
// This may cause serious notification/mail spam after a possible crash | ||
// That's why we make a simple time check to make sure feeds are new | ||
|
||
const date = new Date(item.date); | ||
// Let's compare the dates and make sure the feed a new feed. | ||
if (date.getTime() > bootTime.getTime()) { | ||
const feedData = utils.parseFeedData(item); | ||
// First, try to send the push notification | ||
await utils.sendPushNotification(config, feedData); | ||
|
||
// Now try to send the email | ||
await utils.sendEmailNotification(config, feedData); | ||
|
||
console.log('Successfully notified about the feed!'); | ||
|
||
} | ||
}); | ||
|
Oops, something went wrong.