-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (34 loc) · 1.02 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
var express = require("express");
var methodOverride = require("method-override");
var bodyParser = require("body-parser");
require("dotenv").config();
var CronJob = require("cron").CronJob;
var app = express();
app.use(methodOverride("_method"));
app.use(
express.urlencoded({
extended: true,
})
);
app.use(express.static(__dirname + "/public"));
app.get("/", (req, res) => {
return res.json({ status: "Success", msg: "Hello this is a test" });
});
//Use node-cron to check how the scheduler functionality is working, comment it out before deploying
app.get("/check", async (req, res) => {
var job = new CronJob(
"* * * * * *",
function () {
console.log("You will see this message every second");
// ENTER YOUR TASK HERE
},
null,
true,
"America/Los_Angeles"
);
job.start();
return res.json({status:"Success", msg:"Route launched"});
});
app.listen(process.env.PORT || 3000, process.env.ID, function (req, res) {
console.log("Server has started for HerokuScheduler at PORT 3000");
});