-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (29 loc) · 878 Bytes
/
app.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
const express = require("express");
const app = express();
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const cors = require("cors");
require("dotenv/config");
//Middlwares
app.use(bodyParser.json());
app.use(cors());
app.use(express.static('public'));
//Import routes
const channelsRoute = require("./routers/channels");
const categoriesRoute = require("./routers/category");
const uploadRoute = require("./routers/upload");
app.use("/channels", channelsRoute);
app.use("/category", categoriesRoute);
app.use("/upload", uploadRoute);
//Routes
app.get("/", (req, res) => {
res.send("We are on home");
});
app.get("/channels", (req, res) => {
res.send("We are on Channels");
});
//Connect to DB
mongoose.connect(process.env.DB_CONNECTION, { useNewUrlParser: true }, () => {
console.log("connected to DB!");
});
app.listen(9000);