Skip to content

Commit 2a251f9

Browse files
committed
🔒 jest testing
1 parent f2b08f1 commit 2a251f9

File tree

6 files changed

+5704
-514
lines changed

6 files changed

+5704
-514
lines changed

Diff for: FrontEnd/profile.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h5 id="username">
9090

9191
<div class="row">
9292
<div class="col-md-6">
93-
<label>Events</label>
93+
<label>Events Registered</label>
9494
</div>
9595
<div class="col-md-6">
9696
<ul id="events-list">

Diff for: backend/controllers/eventbritecontroller.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const axios = require("axios");
2+
3+
4+
async function getOrganizations(apiToken) {
5+
try {
6+
const url = "https://www.eventbriteapi.com/v3/users/me/organizations/";
7+
8+
const response = await axios.get(url, {
9+
headers: {
10+
Authorization: `Bearer ${apiToken}`,
11+
},
12+
});
13+
14+
15+
return response.data;
16+
} catch (error) {
17+
console.error("Error fetching organizations from Eventbrite API:", error);
18+
throw new Error("Failed to fetch organizations from Eventbrite API");
19+
}
20+
}
21+
22+
23+
24+
module.exports = {
25+
getOrganizations,
26+
};

Diff for: backend/index.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ const sgMail = require('@sendgrid/mail');
1010
require('dotenv').config();
1111

1212
app.use(cors());
13-
1413
app.use(express.json());
1514
app.use(morgan());
1615
app.use(express.urlencoded({ extended: true }));
1716

18-
1917
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
2018

21-
2219
app.post('/api/user/send-registration-email', async (req, res) => {
2320
try {
2421
const { userEmail, eventId } = req.body;
@@ -43,20 +40,24 @@ app.post('/api/user/send-registration-email', async (req, res) => {
4340
}
4441
});
4542

46-
47-
4843
const port = process.env.PORT || 8000;
4944

5045
app.use('/api/user', userRoute);
5146
app.use('/api/interest', interestRoute);
5247

53-
mongoose.connect(process.env.MONGO_URI)
54-
.then(() => {
48+
async function connectToDatabase() {
49+
try {
50+
await mongoose.connect(process.env.MONGO_URI, {
51+
useNewUrlParser: true,
52+
useUnifiedTopology: true,
53+
});
5554
console.log('Connected to MongoDB');
5655
app.listen(port, () => {
5756
console.log(`Example app listening on port ${port}!`);
5857
});
59-
})
60-
.catch((err) => {
58+
} catch (err) {
6159
console.error('Error connecting to MongoDB:', err);
62-
});
60+
}
61+
}
62+
63+
connectToDatabase();

0 commit comments

Comments
 (0)