-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (31 loc) · 1 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
const express =require ("express");
var cookieParser = require('cookie-parser');
var cors = require('cors');
const path = require('path');
// import files //
const Souce = require("./Models/soucemodels");
const pizzasRoute = require('./Routers/PizzaRouter');
const soucesRoute = require('./Routers/SouceRouter');
const userRoute = require('./Routers/UserRouter');
const db = require("./dbconnected");
const paymentRoute = require("./Routers/PaymentRouter");
// setup server //
const app = express();
app.use(express.json());
app.use(cors())
app.use(cookieParser());
// import routes //
app.use('/Pizza',pizzasRoute);
app.use('/Souce',soucesRoute);
app.use('/Users',userRoute);
app.use('/Orders',paymentRoute);
if(process.env.NODE_ENV ==='production')
{
app.use('/' , express.static('client/build'))
app.get('*' , (req , res)=>{
res.sendFile(path.resolve(__dirname , 'client/build/index.html'))
})
}
// running port //
const port=process.env.PORT || 8000;
app.listen(port,() =>`server running`);