-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
66 lines (48 loc) · 1.53 KB
/
index.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
55
56
57
58
59
60
61
62
63
64
65
66
const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
require("dotenv").config();
const cors = require("cors");
const app = express();
app.use(cors());
require('./models/Customer');
require('./models/Transfers');
//Connection to DB
mongoose.connect(
"mongodb+srv://zeinab-moawad:482000zeinab@bankingsystem.6chtqhn.mongodb.net/test",
{
useNewUrlParser: true,
useUnifiedTopology: true,
}
)
.then(() => console.log("MongoDB has been connected"))
.catch((err) => console.log(err));
//Connection to DB
// mongoose.connect(
// process.env.MONGODB_CONNECTION_STRING,
// {
// useNewUrlParser: true,
// useUnifiedTopology: true,
// }
// )
// .then(() => console.log("MongoDB has been connected"))
// .catch((err) => console.log(err));
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json())
require('./routes/customerRoute.js')(app)
require('./routes/tranferRoute.js')(app)
const PORT = process.env.PORT || 5000;
// Accessing the path module
const path = require("path");
// Step 1:
app.use(express.static(path.resolve(__dirname, "./client/build")));
// Step 2:
app.get("*", function (request, response) {
response.sendFile(path.resolve(__dirname, "./client/build", "index.html"));
});
// //PortNo to listen on
// app.use(express.json())
app.listen(PORT, () => {
console.log(`Running on port ${PORT}`);
});