-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
115 lines (62 loc) · 2.48 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
var express = require('express');
const cors = require('cors'); // Import the cors middleware
var app = express();
require('dotenv').config(); // Load environment variables from .env file
const cloudinary = require('cloudinary').v2;
cloudinary.config({
cloud_name: process.env.CLN_CLOUD_NAME,
api_key: process.env.CLN_API_KEY,
api_secret: process.env.CLN_API_SECRET,
});
// routes import
const builderRoutes = require('./routes/builderRoutes');
const societyRoutes = require('./routes/societyRoutes');
const memberRoutes = require('./routes/memberRoutes');
const wingRoutes = require('./routes/wingRoutes');
const flatRoutes = require('./routes/flatRoutes');
const ownerRoutes = require('./routes/ownerRoutes');
const tenantRoutes = require('./routes/tenantRoutes');
const ownerFamilyRoutes = require('./routes/ownerFamilyRoutes');
const tenantFamilyRoutes = require('./routes/tenantFamilyRoutes');
const penaltyRoutes = require('./routes/penaltyRoutes');
const ownerPenaltyRoutes = require('./routes/ownerPenaltyRoutes');
const authenticateToken = require('./middleware/authMiddleware');
const complaintRoutes = require('./routes/complaintRoutes');
const contactRoutes = require('./routes/contactRoutes');
// Import the cron job module
require('./cronJob');
// connecting to database
const connectDB = require('./db');
connectDB();
// middleware
app.use(cors());
// this code is for accepting data in port request
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// app.use(authenticateToken); // authentication
// image routes
// all the routes
app.use('/api/builders', builderRoutes);
app.use('/api/members', memberRoutes);
app.use('/api/societies', societyRoutes);
app.use('/api/wings', wingRoutes);
app.use('/api/flats', flatRoutes);
app.use('/api/owners', ownerRoutes);
app.use('/api/tenants', tenantRoutes);
app.use('/api/ownerFamilies', ownerFamilyRoutes);
app.use('/api/tenantFamilies', tenantFamilyRoutes);
app.use('/api/penalties', penaltyRoutes);
app.use('/api/ownerPenalties', ownerPenaltyRoutes);
app.use('/api/complaints', complaintRoutes);
app.use('/api/contacts', contactRoutes);
// admin routes
// app.use(adminBroApp);
app.get('/', function(req, res){
res.send("Hello world!");
});
// app.use(admin.options.rootPath, adminRouter)
const port = process.env.PORT || 3000;
app.listen(port, "0.0.0.0" ,()=> {
console.log(`Server is running on http://localhost:${port}`);
});