-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (44 loc) · 1.48 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const express = require("express");
require("dotenv").config();
const app = express();
const cors = require("cors");
app.use(express.json());
const bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({ extended: true }));
const mongoose = require("mongoose");
mongoose
.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("DB Connected");
});
const authMiddleware = require("./middleware/auth");
app.use(cors());
//send response api is working
app.get("/", (req, res) => {
res.send("API is working");
});
//api for authentication
app.use("/api/auth", require("./routes/auth"));
//api for news
app.use("/api/news", require("./routes/news"));
//endpoint for events
app.use("/api/events", require("./routes/Events"));
app.use(["/api/officer","/api/officials"],authMiddleware)
app.use("/api/officer", require("./routes/officer"));
//endpoint for officials
app.use("/api/officials", require("./routes/Officials"));
//endpoint for notifications
app.use("/api/notifications", require("./routes/Notifications"));
//get score
app.use("/api/score", require("./routes/score"));
// app.use("/getprice", require("./routes/getprice"));
// app.use("/auth", require("./routes/auth"));
// app.use("/test", require("./routes/testing/test"));
// app.use('/',(req,res)=>{
// res.send("backend is up and running")
// })
const PORT = process.env.PORT;
app.listen(PORT, () => console.log(`Listening at ${PORT}`));