-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
81 lines (57 loc) · 2.64 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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require("dotenv").config();
const path = require("path")
const express = require("express");
const cors = require("cors");
// Controllers
const createWallet = require("./backend/controllers/createWallet");
const transfer = require("./backend/controllers/transfer");
const confirmation = require("./backend/controllers/confirmation");
const listTransactions = require("./backend/controllers/listTransactions");
const listPayments = require("./backend/controllers/listPayments");
const allWallets = require("./backend/controllers/allWallets");
const allCustomers = require("./backend/controllers/allCustomers");
const createCustomer = require("./backend/controllers/createCustomer");
const createPayment = require("./backend/controllers/createPayment");
const feedback = require("./backend/controllers/feedback");
// MongoDB Cloud Connection
const conectDB = require("./backend/config/db");
// Initializing APP
const app = express();
// Midlewares
app.use(express.json());
app.use(cors());
// Database Connection
conectDB();
// ------------------------ Creating A Wallet ------------------------ \\
app.post("/api/ewallet", createWallet);
// -------------------- Money Transfer Between Wallet ------------------- \\
app.post("/api/transfer", transfer);
// ------------------------ Money Transfer Confirmation ------------------- \\
app.post("/confirmation", confirmation);
// ------------------------ Creating A Customer ------------------------ \\
app.post("/api/createCustomer", createCustomer);
// ------------------------ Creating Payment ------------------------ \\
app.post("/api/createPayment", createPayment);
// ------------------ List Transactions ---------------- \\
app.get("/api/listTransactions", listTransactions);
// ------------------ List Payments ---------------- \\
app.get("/api/listPayments", listPayments);
// --------------------------- List Of Created Wallets --------------------------- \\
app.get("/api/allWallets", allWallets);
// --------------------------- List Of Created Customers --------------------------- \\
app.get("/api/allCustomers", allCustomers);
// --------------------------- Save Feedback ---------------------------- \\
app.post("/api/feedback", feedback);
// Production
if(process.env.NODE_ENV === 'production'){
app.use(express.static(path.join(__dirname, '/frontend/build')));
app.get("*", (req, res)=>{
res.sendFile(path.join(__dirname, 'frontend',"build","index.html"));
})
}else{
app.get("/", (req,res)=>{
res.send("Hey There , Greetings From The Server. Have a Good Day :)")
})
}
const port = process.env.PORT || 5000;
app.listen(port, () => console.log("serve at http://localhost:5000"));