-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
44 lines (35 loc) · 1.04 KB
/
server.js
File metadata and controls
44 lines (35 loc) · 1.04 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const express = require('express')
const cors = require('cors')
const morgan = require('morgan')
const dotenv = require('dotenv')
const colors = require('colors')
const connectDb = require('./config/connectDb')
const path = require("path");
//config .env
dotenv.config();
//connectdb
connectDb();
//rest object
const app = express();
//middleware
app.use(morgan('dev'))
app.use(express.json())
app.use(cors())
//routes
app.use('/api/v1/users', require('./routes/userRoute'))
app.use('/api/v1/transactions', require('./routes/transactionRoute'))
app.use(express.static(path.join(__dirname, "./client/build")));
app.get("*", function (req, res) {
res.sendFile(path.join(__dirname, "./client/build/index.html"));
});
//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"))
})
//creation of port
const PORT = 8080 || process.env.PORT
//listening the server
app.listen(PORT, ()=>{
console.log(`Server running on Port: ${PORT}`)
})