Skip to content

Commit

Permalink
added home route to confirm api status on ping
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxada committed Dec 14, 2023
1 parent 7cdb82b commit 7a083f6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ jobs:
--env-file /home/${{ secrets.USERNAME }}/.env \
--restart=always \
--name ${{ env.IMAGE_NAME }} \
${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.IMAGE_NAME }}:${{ github.sha }}
4 changes: 2 additions & 2 deletions providers/github/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ const handleOAuthCallback = async (req, res) => {
*/
const githubAuthCallback = (app) => {
if (process.env.NODE_ENV === "production") {
app.post("/api/callback/gitlab", handleOAuthCallback);
app.post("/api/callback/github", handleOAuthCallback);
} else if (process.env.NODE_ENV === "development") {
app.get("/api/callback/gitlab", handleOAuthCallback);
app.get("/api/callback/github", handleOAuthCallback);
}
};

Expand Down
30 changes: 24 additions & 6 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ const badgedRepos = async (req, res) => {
};

const setupRoutes = (app) => {
app.get("/api", (req, res) => {
try {
res.json({ message: "Project Badging server up and running" });
} catch (error) {
console.error(error);

if (error.statusCode && error.statusCode !== 200) {
res.status(error.statusCode).json({
error: "Error",
message: "our bad, something is wrong with the server configuration",
});
} else {
res.status(500).json({
error: "Internal Server Error",
message: "An unexpected error occurred at our end",
});
}
}
});

app.get("/api/auth/github", (req, res) => {
githubAuth(req, res);
});
Expand All @@ -88,16 +108,14 @@ const setupRoutes = (app) => {
gitlabAuth(req, res);
});

//redirects
app.get("/api/callback/github", (req, res) => {
githubAuthCallback(req, res);
});
//callbacks
githubAuthCallback(app);
gitlabAuthCallback(app);

app.get("/api/badgedRepos", badgedRepos);
app.get("/api/badged-repos", badgedRepos);
app.post("/api/repos-to-badge", reposToBadge);

// github_routes.setupGitHubRoutes(app);
gitlabAuthCallback(app);
};

module.exports = {
Expand Down

0 comments on commit 7a083f6

Please sign in to comment.