-
Notifications
You must be signed in to change notification settings - Fork 28
/
app.js
33 lines (26 loc) · 879 Bytes
/
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
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
var schedule = require("node-schedule");
var news = require("./controllers/newsController");
const port = process.env.PORT || 80;
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(bodyParser.raw());
app.set("view engine", "ejs");
app.set("views", "views");
//Serve static files
app.use(express.static(path.join(__dirname, "public")));
//Main Route
const mainRoute = require("./routes/mainRoute");
app.use("/", mainRoute);
var j = schedule.scheduleJob("1 1 * * * *", function () {
//run every hour at minute 1 and 1 sec
console.log("Index File Updation Request Send.");
news.news_get();
});
app.listen(port);
console.log(`Listening at port ${port}`);
//Updating Data First Launch
news.news_get();