-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (27 loc) · 902 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
32
33
34
const express = require("express");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const dotenv = require("dotenv");
const app = express();
const port = 8080;
dotenv.config();
// Middleware
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
const communitiesRoutes = require("./routes/communities");
const mediaRoutes = require("./routes/media");
const userRoutes = require("./routes/users");
app.use("/api/communities", communitiesRoutes);
app.use("/api/media", mediaRoutes);
app.use("/api/users", userRoutes);
app.route("/", (req, res) => {
res.send("hello world");
});
mongoose.connect(
process.env.MONGODB_URI,
{ useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false },
() => console.log("Connecting to mongoDB")
);
app.listen(port, "0.0.0.0", () => {
console.log(`App listening on port ${port}`);
});