-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (26 loc) · 836 Bytes
/
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
require("dotenv").config();
const express = require("express");
const mongoose = require("mongoose");
var cors = require("cors");
const app = express();
//cors and express
app.use(express.json());
app.use(cors());
//routes
const siteRoutes = require("./routes/site_routes");
const votingRoutes = require("./routes/voting_routes");
const geminiRoutes = require("./routes/gemini_routes");
app.use("/api/sites", siteRoutes);
app.use("/api/voting", votingRoutes);
app.use("/api/gemini", geminiRoutes);
//MONGODB STUFF
mongoose
.connect(process.env.MONGODB_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Connected to MongoDB");
app.listen(5001, () => console.log("Server running on port 5001"));
})
.catch((err) => console.error("Could not connect to MongoDB...", err));