-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (39 loc) · 1.31 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
// const express = require('express');
// const mongoose = require('mongoose');
// const app = express();
// const port = 3000;
// const uri = "mongodb+srv://ahmedawsaf:AwsafisKing@travelcluster.p1ggd6r.mongodb.net/tour?retryWrites=true&w=majority";
// mongoose.connect(uri)
// .then(() => {
// console.log('Connected to MongoDB');
// // Start your Express server
// app.listen(port, () => {
// console.log(`Server is listening at http://localhost:${port}`);
// });
// })
// .catch((error) => {
// console.error('Failed to connect to MongoDB:', error);
// });
// server.js
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const authRoutes = require('./routes/auth');
const tour = require('./routes/tour');
const guide = require('./routes/guide');
const transaction = require('./routes/transaction')
const app = express();
const PORT = 4000;
// Middleware
app.use(bodyParser.json());
// Connect to MongoDB
mongoose.connect("")
.then(() => console.log('MongoDB connected'))
.catch(err => console.error(err));
// Routes
app.use('/tour', tour);
app.use('/api/auth', authRoutes);
app.use('/guide', guide);
app.use('/transaction', transaction);
// Start server
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));