-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (36 loc) · 1.08 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require("dotenv").config();
var { verify } = require("./jobs/verify");
// DB connection
var MONGODB_URL = process.env.MONGODB_URL;
var mongoose = require("mongoose");
mongoose
.connect(MONGODB_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => {
//don't show the log when it is test
if (process.env.NODE_ENV !== "test") {
console.log("Connected to %s", MONGODB_URL);
console.log("App is running ... \n");
}
})
.catch((err) => {
console.error("App starting error:", err.message);
process.exit(1);
});
var db = mongoose.connection;
const Agenda = require("agenda");
const agenda = new Agenda({
db: {
address: MONGODB_URL,
collection: "agendaJobs",
},
maxConcurrency: 1,
});
//Define the background task to verify the package
agenda.define("verify package", verify.packageVerification);
(async function () {
// IIFE to give access to async/await
await agenda.start();
})();
// agenda.define("get package programs", programs.getPrograms);
// const job = agenda.create("get package programs", package);
// await job.save();