forked from akarshroot/agritech-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
51 lines (47 loc) · 1.81 KB
/
app.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
const express = require("express");
const cors = require("cors")
const { default: mongoose } = require("mongoose");
const web3Router = require("./routes/web3Router");
const web3RouterFunding = require("./routes/web3RouterFunding");
const app = express()
const { info } = require("./utils/logger");
const authRoutes = require("./routes/AuthRoutes")
const userRoutes = require("./routes/UserRoutes")
const storeRoutes = require("./routes/StoreRoutes")
const walletRoutes = require("./routes/WalletRoutes")
const managementRoutes = require("./routes/ManagementRoutes")
const refreshTokenRoute = require("./routes/refreshToken")
const cookies = require("cookie-parser");
const path = require("path")
const web3RouterVoting = require("./routes/web3RouterVoting");
const generalDataRoutes = require("./routes/GeneralDataRoutes");
app.use(cookies());
app.use(cors({
origin: [
"http://localhost:3000",
"http://localhost:3003",
"https://platform-agritech.web.app",
"https://35.192.7.28/"
],
credentials: true
}))
app.use(express.json())
app.use(express.static('build'));
mongoose.connect(`mongodb+srv://admin:${process.env.MONGO_PASS}@maincluster.yajbyem.mongodb.net/?retryWrites=true&w=majority`)
mongoose.connection.on('connected', async function () {
info('Mongoose connection open');
});
app.use('/api/web3/wallet', web3Router)
app.use('/api/web3/fundingContracts', web3RouterFunding)
app.use('/api/web3/votingContracts', web3RouterVoting)
app.use("/api/auth", authRoutes)
app.use("/api/refreshToken", refreshTokenRoute)
app.use("/api/user", userRoutes)
app.use("/api/management", managementRoutes)
app.use("/api/store", storeRoutes)
app.use("/api/wallet/", walletRoutes)
app.use("/api/data/", generalDataRoutes)
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '/build/index.html'));
});
module.exports = app