-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (35 loc) · 1.06 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
const express = require("express");
const mongoose = require("mongoose");
const cors = require("cors");
require("dotenv").config();
// set up express
const app = express();
app.use(express.json());
app.use(cors());
// SEND MAIL
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`The server has started on port: ${PORT}`));
// set up mongoose
mongoose.connect(
process.env.MONGODB_CONNECTION_STRING,
{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
},
(err) => {
if (err) {
throw err;
}
console.log("MongoDB connection established");
}
);
// set up routes
app.use("/users", require("./routes/userRouter"));
app.use("/api", require("./routes/uploadVideoRouter"));
app.use("/api", require("./routes/uploadPhotoRouter"));
app.use("/api", require("./routes/videoListRouter"));
app.use("/api", require("./routes/photoListRouter"));
app.use("/api", require("./routes/sendMailRouter"));
app.use("/api/videos", express.static("media/uploads"));
app.use("/api/photos", express.static("media/photos"));