-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
45 lines (28 loc) · 1.02 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
40
41
42
43
44
45
require('dotenv').config();
const express = require("express");
const connectDB = require('./Controllers/database.Controller');
const morgan = require("morgan"); // the logger
const userRoute = require("./routes/user.Route")
const authRoute = require("./routes/auth.Route")
const postRoutes = require('./Routes/post.Route');
const commentRoutes = require('./Routes/comment.Route');
// create express app
const app = express()
connectDB();
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
if (process.env.NODE_ENV === "development") {
app.use(morgan("dev"));
console.log(`mode: ${process.env.NODE_ENV}`)
}
app.use("/test", (req, res) => {
console.log("hey in url test ");
})
app.use('/api/users', userRoute)
app.use('/api/auth', authRoute)
app.use('/api/posts', postRoutes);
app.use('/api/comments', commentRoutes);
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log("Server listening on port " + port);
});