-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
25 lines (22 loc) · 1.03 KB
/
app.js
File metadata and controls
25 lines (22 loc) · 1.03 KB
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
const express = require('express');
const bodyParser = require('body-parser');
const categoryRoutes = require('./routes/category.routes');
const productRoutes = require('./routes/product.routes');
const authRoutes = require('./routes/auth.routes');
const roleRoutes = require('./routes/role.routes');
const orderRoutes = require('./routes/order.routes');
const {PORT} = require('./config/serverConfig');
const {sequelize} = require('./models/index');
const app = express();
//app.use() is using the provided middleware for every incoming requrest to the server
// We need a body parser middleware, that will help express to read all the query and body params in a readable form for node.js
app.use(bodyParser.urlencoded({extended: true}));
categoryRoutes(app);
productRoutes(app);
authRoutes(app);
roleRoutes(app);
orderRoutes(app);
app.listen(PORT,async()=>{
await sequelize.sync(); // this to sync all the models (it will create the through table User_Roles in db)
console.log('server is listening to port: ',PORT);
});