Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: set up agenda controller for cron jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwigoric committed Nov 22, 2023
1 parent 0d75c3d commit aa01758
Show file tree
Hide file tree
Showing 4 changed files with 1,211 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"watch": "nodemon --watch src index.js"
},
"dependencies": {
"agenda": "^5.0.0",
"argon2": "0.30.3",
"cookie-parser": "~1.4.6",
"cors": "^2.8.5",
Expand Down
4 changes: 4 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ await database.init().catch((err) => {
process.exit(1)
})

// Initialize schedules
import agenda from './schedules/index.js'
await agenda.init()

// Routes
import indexRouter from './routes/index.js'
import usersRouter from './routes/users.js'
Expand Down
17 changes: 17 additions & 0 deletions src/schedules/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Packages
import Agenda from 'agenda'
import mongoose from 'mongoose'

class AgendaController {
instance = null

init() {
this.instance = new Agenda()

return this.instance.mongo(mongoose.connection.db, 'agenda-jobs')
}
}

const agendaController = new AgendaController()

export default agendaController
Loading

0 comments on commit aa01758

Please sign in to comment.