Skip to content

Commit

Permalink
error info added
Browse files Browse the repository at this point in the history
  • Loading branch information
Piootrekk committed Feb 5, 2024
1 parent 2bdc142 commit 7f72133
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ jobs:
with:
service-id: ${{ secrets.MY_RENDER_SERVICE_ID }}
api-key: ${{ secrets.MY_RENDER_API_KEY }}
wait-for-success: true
29 changes: 16 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ app.use((req, res, next) => {
next();
});


app.get("/", (req, res) => {
res.redirect("/api-docs");
});
Expand All @@ -33,9 +32,10 @@ app.get("/get/:path(*)", async (req, res) => {

res.json(response.data);
} catch (error) {
console.error("Error in /get endpoint:", error);
res.status(500).json({
error: "An error occurred while processing the API request.",
res.status(error.response.status).json({
message: error.message,
status: error.response.status,
code: error.code,
path: req.params.path,
});
}
Expand All @@ -56,9 +56,10 @@ app.post("/post/:path(*)", async (req, res) => {

res.json(response.data);
} catch (error) {
console.error("Error in /post endpoint:", error);
res.status(500).json({
error: "An error occurred while processing the API request.",
res.status(error.response.status).json({
message: error.message,
status: error.response.status,
code: error.code,
path: req.params.path,
});
}
Expand All @@ -72,9 +73,10 @@ app.put("/put/:path(*)", async (req, res) => {
const response = await axios.put(decodedPath, req.body);
res.json(response.data);
} catch (error) {
console.error("Error in /put endpoint:", error);
res.status(500).json({
error: "An error occurred while processing the API request.",
res.status(error.response.status).json({
message: error.message,
status: error.response.status,
code: error.code,
path: req.params.path,
});
}
Expand All @@ -88,9 +90,10 @@ app.delete("/delete/:path(*)", async (req, res) => {
const response = await axios.delete(decodedPath);
res.json(response.data);
} catch (error) {
console.error("Error in /delete endpoint:", error);
res.status(500).json({
error: "An error occurred while processing the API request.",
res.status(error.response.status).json({
message: error.message,
status: error.response.status,
code: error.code,
path: req.params.path,
});
}
Expand Down

0 comments on commit 7f72133

Please sign in to comment.