-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
54 lines (36 loc) · 1006 Bytes
/
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
46
47
48
49
50
51
52
53
54
const express = require('express')
const cors = require('cors')
const morgan = require('morgan')
const color = require('colors');
const dotenv = require('dotenv')
const connectDb = require("./config/connectDb")
const path = require('path')
// config dot env file
dotenv.config()
//database call
connectDb()
//rest object
const app= express()
//middlewares
app.use(morgan('dev'))
app.use(express.json())
app.use(cors())
//routes
// app.get('/',(req,res)=>{
// res.send("<h1>hello from server </h1>")
// })
//user routes
app.use('/api/v1/users',require('./routes/userRoutes'))
//transection routers
app.use("/api/v1/transections",require("./routes/transectionRoutes"))
//static file
app.use(express.static(path.join(__dirname,'./client/build')))
app.get('*',function(req,res){
res.sendFile(path.join(__dirname,'./client/build/index.html'))
})
//port
const PORT = 8081 || process.env.PORT
//listend server
app.listen(PORT,()=>{
console.log('server running on port '+ PORT)
})