Skip to content

Commit

Permalink
Fs/issue 147 cron notifications (#150)
Browse files Browse the repository at this point in the history
* Added cron library.

* Created cron to run notifications using cronJob.

* Added cron to the server.

* Activate a cron to Run everyday at 12:00AM and logging

* Forgot that is not semicolon here :p
  • Loading branch information
wharley authored and alexanmtz committed Aug 23, 2018
1 parent 5eed7a4 commit 108a445
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const CronJob = require('cron').CronJob

const job = new CronJob({
// Seconds: 0-59 Minutes: 0-59 Hours: 0-23 Day of Month: 1-31 Months: 0-11 (Jan-Dec) Day of Week: 0-6 (Sun-Sat)
cronTime: '0 0 0 * * *', // everyday at 12:00AM
onTick: () => {
const d = new Date()
// eslint-disable-next-line no-console
console.log('Log to confirm cron job run at', d)
}
})

module.exports = { job }
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"cors": "^2.8.4",
"cron": "^1.4.0",
"dateformat": "^3.0.3",
"dotenv": "^4.0.0",
"eslint": "^4.19.1",
Expand Down
3 changes: 3 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ require('./config/passport')
const load = require('./modules/load/load')
const feed = require('feed-read')

const { job } = require('./cron')
job.start()

if (process.env.NODE_ENV !== 'production') {
app.use(cors())
}
Expand Down

0 comments on commit 108a445

Please sign in to comment.