-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (30 loc) · 1.01 KB
/
index.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
const express = require("express");
const dotenv = require("dotenv");
const cors = require("cors");
const { task } = require("./dependencies/cron-jobs");
dotenv.config(); // configure before importing connectToDatabase;
process.on("unhandledRejection", (reason, promise) => {
console.log("Reason:", reason);
});
const { connectToDatabase } = require("./dependencies/db");
connectToDatabase();
const app = express();
const PORT = process.env.PORT || "5000";
app.use(cors());
app.use(express.json());
app.use("/files", express.static("uploads"));
// Available endpoints
const audioBookRouter = require("./api/routes/audioBook.route");
app.use("/api/audioBook", audioBookRouter);
const authRouter = require("./api/routes/auth.route");
app.use("/api/auth", authRouter);
const userRouter = require("./api/routes/user.route");
app.use("/api/user", userRouter);
app.use("/", (req, res) => {
return res.status(404).json({
message: "No such route found",
});
});
app.listen(PORT, () => {
console.log("server is running");
});