-
Notifications
You must be signed in to change notification settings - Fork 10
/
app.js
51 lines (41 loc) · 997 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const express = require('express');
const dotenv = require('dotenv');
const morgan = require('morgan');
const cors = require('cors');
const connectDB = require('./config/db');
// Load config
dotenv.config();
connectDB();
const app = express();
app.use(cors());
// Body parser
app.use(
express.urlencoded({
extended: false,
})
);
app.use(express.json());
// Logging
if (process.env.NODE_ENV === 'development') {
app.use(morgan('dev'));
}
//home page route
app.get('/', (req, res) => {
const response = {
error: false,
msg: 'Welcome to Renting System!',
};
res.send(response);
});
// Routes
app.use('/buyer', require('./routes/buyer'));
app.use('/seller', require('./routes/seller'));
app.use('/product', require('./routes/product'));
app.use('/order', require('./routes/order'));
const PORT = process.env.PORT || 3000;
app.listen(
PORT,
console.log(
`Server running in ${process.env.NODE_ENV} mode on port ${PORT}`
)
);