-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (36 loc) · 1.19 KB
/
server.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
require("dotenv").config();
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors({ origin: true }));
app.use(bodyParser.json());
const dbConfig = require("./config/database.config.js");
const mongoose = require("mongoose");
mongoose.Promise = global.Promise;
mongoose
.connect(dbConfig.url)
.then(() => {
console.log("Databse Connected Successfully!!");
})
.catch((err) => {
console.log("Could not connect to the database", err);
process.exit();
});
app.get("/", (req, res) => {
res.json({ message: "Hello World!" });
});
app.listen(3000, () => {
console.log("Server is listening on port 3000");
});
const UserRoute = require("./app/routes/user-routes.js");
const PostRoute = require("./app/routes/post-routes.js");
const AuthRoute = require("./app/routes/auth-routes.js");
// const CommentRoute = require("./app/routes/comment-routes.js");
const MLRoute = require("./app/routes/ml-routes.js");
app.use("/user", UserRoute);
app.use("/post", PostRoute);
app.use("/login", AuthRoute);
// app.use("/comment", CommentRoute);
// app.use("/ml", MLRoute);