Skip to content

Commit 2050a59

Browse files
Merge pull request #54 from DesmondSanctity/event-badging-submit-api
Event badging submit api
2 parents 24a4f24 + afea26a commit 2050a59

File tree

7 files changed

+39
-64
lines changed

7 files changed

+39
-64
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
title: 'Please provide a concise and informative title that summarizes the issue:
5-
e.g. [BUG]<X> not working for <Y>'
4+
title:
5+
"Please provide a concise and informative title that summarizes the issue:
6+
e.g. [BUG]<X> not working for <Y>"
67
labels: bug
7-
assignees: ''
8-
8+
assignees: ""
99
---
1010

1111
**Describe the bug**
1212
_A clear and concise description of what the bug is. Be specific and clear about what you were trying to do when the bug occurred._
1313

1414
**Steps To Reproduce**
1515
_List the exact steps someone can take to reproduce the issue._
16+
1617
1. Go to '...'
1718
2. Click on '....'
1819
3. Scroll down to '....'
@@ -26,16 +27,18 @@ _If applicable, add screenshots/screen recordings to help explain your problem._
2627

2728
**Desktop specifications**
2829
_Please complete the following information if applicable):_
29-
- OS: [e.g. iOS]
30-
- Browser [e.g. chrome, safari]
31-
- Version [e.g. 22]
30+
31+
- OS: [e.g. iOS]
32+
- Browser [e.g. chrome, safari]
33+
- Version [e.g. 22]
3234

3335
**Smartphone specifications**
3436
_Please complete the following information if applicable):_
35-
- Device: [e.g. iPhone6]
36-
- OS: [e.g. iOS8.1]
37-
- Browser [e.g. stock browser, safari]
38-
- Version [e.g. 22]
37+
38+
- Device: [e.g. iPhone6]
39+
- OS: [e.g. iOS8.1]
40+
- Browser [e.g. stock browser, safari]
41+
- Version [e.g. 22]
3942

4043
**Additional context**
4144
• Provide any additional information that might help understand the issue. This could include links to relevant code snippets, configuration files, or other resources.

.github/ISSUE_TEMPLATE/doc-feedback.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
name: Doc feedback
33
about: Help us improve the docs
4-
title: 'Briefly describe the improvement you are requesting e.g. [DOC]: Improve clarity
5-
of X'
6-
labels: ''
7-
assignees: ''
8-
4+
title:
5+
"Briefly describe the improvement you are requesting e.g. [DOC]: Improve clarity
6+
of X"
7+
labels: ""
8+
assignees: ""
99
---
1010

1111
**Description**

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: 'Please provide a concise and informative title that summarizes the issue:
5-
e.g. [FEATURE]: [Describe the desired feature]'
4+
title:
5+
"Please provide a concise and informative title that summarizes the issue:
6+
e.g. [FEATURE]: [Describe the desired feature]"
67
labels: enhancement
7-
assignees: ''
8-
8+
assignees: ""
99
---
1010

1111
**Is your feature request related to a problem? Please describe.**

.github/pull_request_template.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
**Summary:**
44

5-
* Briefly describe the changes introduced in this PR.
6-
* Make a reference to the related issue you are resolving.
5+
- Briefly describe the changes introduced in this PR.
6+
- Make a reference to the related issue you are resolving.
77

88
**Changes:**
99

10-
* List the specific files modified and a short summary of the changes made.
11-
* Use bullet points for clarity.
10+
- List the specific files modified and a short summary of the changes made.
11+
- Use bullet points for clarity.
1212

1313
**Testing:**
1414

15-
* Describe the steps taken to test the changes.
16-
* Mention any automated tests added or modified.
15+
- Describe the steps taken to test the changes.
16+
- Mention any automated tests added or modified.
1717

1818
**Additional Notes:**
1919

20-
* Include any relevant information not covered above.
21-
* Ask questions or provide guidance to reviewers.
20+
- Include any relevant information not covered above.
21+
- Ask questions or provide guidance to reviewers.

providers/github/auth.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,8 @@ const handleOAuthCallback = async (req, res) => {
194194
}
195195
};
196196

197-
/**
198-
* Sets up the provided Express app routes for GitLab
199-
* @param {*} app Express application instance
200-
*/
201-
const githubAuthCallback = (app) => {
202-
if (process.env.NODE_ENV === "production") {
203-
app.post("/api/callback/github", handleOAuthCallback);
204-
} else if (process.env.NODE_ENV === "development") {
205-
app.get("/api/callback/github", handleOAuthCallback);
206-
}
207-
};
208-
209197
module.exports = {
210198
githubAuth,
211-
githubAuthCallback,
212199
handleOAuthCallback,
213200
githubApp,
214201
};

providers/gitlab/auth.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const requestAccessToken = async (code) => {
6565
* @returns A json object with `user_info` and `errors`
6666
* */
6767

68-
const handleOAuthCallback = async (req, res) => {
68+
const handleOAuthCallbackGitlab = async (req, res) => {
6969
const code = req.body.code ?? req.query.code;
7070

7171
const { access_token: accessToken, errors: accessTokenErrors } =
@@ -152,19 +152,7 @@ const handleOAuthCallback = async (req, res) => {
152152
}
153153
};
154154

155-
/**
156-
* Sets up the provided Express app routes for GitLab
157-
* @param {*} app Express application instance
158-
*/
159-
const gitlabAuthCallback = (app) => {
160-
if (process.env.NODE_ENV === "production") {
161-
app.post("/api/callback/gitlab", handleOAuthCallback);
162-
} else if (process.env.NODE_ENV === "development") {
163-
app.get("/api/callback/gitlab", handleOAuthCallback);
164-
}
165-
};
166-
167155
module.exports = {
168156
gitlabAuth,
169-
gitlabAuthCallback,
157+
handleOAuthCallbackGitlab,
170158
};

routes/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ const eventBadging = require("../event_badging/index.js");
44
const github_helpers = require("../providers/github/APICalls.js");
55
const gitlab_helpers = require("../providers/gitlab/APICalls.js");
66
const { getAllEvents } = require("../database/controllers/event.controller.js");
7-
const {
8-
githubAuth,
9-
githubAuthCallback,
10-
githubApp,
11-
gitlabAuth,
12-
gitlabAuthCallback,
13-
} = require("../providers/index.js");
7+
const { githubAuth, githubApp, gitlabAuth } = require("../providers/index.js");
8+
const { handleOAuthCallback } = require("../providers/github/auth.js");
9+
const { handleOAuthCallbackGitlab } = require("../providers/gitlab/auth.js");
1410

1511
/**
1612
* Redirects the user to the GitHub OAuth login page for authentication.
@@ -160,8 +156,9 @@ const setupRoutes = (app) => {
160156
app.get("/api/login", login);
161157

162158
//callbacks
163-
githubAuthCallback(app);
164-
gitlabAuthCallback(app);
159+
app.post("/api/callback/github", handleOAuthCallback);
160+
app.post("/api/callback/gitlab", handleOAuthCallbackGitlab);
161+
165162
app.get("/api/badgedRepos", badgedRepos);
166163
app.post("/api/repos-to-badge", reposToBadge);
167164

0 commit comments

Comments
 (0)