-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (27 loc) · 988 Bytes
/
server.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
const express = require("express");
const dotenv = require("dotenv");
const connectDB = require("./config/db");
const path = require("path");
const cors = require("cors");
const { goalSchedule } = require("./jobs/goal.job");
const { notificationSchedule } = require("./jobs/notification.job");
dotenv.config({ path: "./config/config.env" });
connectDB();
const app = express();
const PORT = process.env.PORT || 5000;
app.use(express.json({ extended: false }));
// CORS
app.use(cors());
// CRON JOBS
goalSchedule();
notificationSchedule();
// ROUTES
app.use("/api/users", require("./routes/user.route"));
app.use("/api/timelogs", require("./routes/timelog.route"));
app.use("/api/goals", require("./routes/goal.route"));
app.use("/api/stats", require("./routes/stats.route"));
app.get("/", (req, res) => {
console.log("Hello world");
return res.status(200).json({ message: "This is TimeOut! API" });
});
app.listen(PORT, () => console.log("This is listening on PORT: " + PORT));