-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (29 loc) · 905 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
const express = require("express");
const app = express();
const cors = require("cors");
const mongoose=require('mongoose')
const port = process.env.PORT
require("dotenv").config();
//rest object
const path=require('path');
//middlwares
app.use(cors());
app.use("/",express.static(path.join(__dirname,"./client/dist")))
app.use(express.json());
//routes
app.use("/api/items", require("./routes/itemRoutes"));
app.use("/api/users", require("./routes/userRoutes"));
app.use("/api/bills", require("./routes/billsRoute"));
//port
const PORT = process.env.PORT || 1234;
//mongoose
// mongoose.connect(process.env.MONGO_URL)
// .then(()=>console.log('DB CONNECTED'))
// .catch((err)=>console.log("something went wrong"))
app.get("*",(req,res)=>{
res.sendFile(path.join(__dirname,"./client/dist/index.html"))
})
//listen
app.listen(PORT, () => {
console.log(`Server Running On Port ${PORT}`);
});