Skip to content

Commit

Permalink
fix: changes for API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalCodes committed Apr 16, 2024
1 parent 99d90ad commit 1619bf8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Milan is a hub to **connect** NGOs, Charities, and the world to **collaborate**
<div align="center" >

<div align="center" >
<a href="https://api.milanhub.org/"><img alt="C" src="https://img.shields.io/badge/Production%20Release-07C160?style=for-the-badge&logo=vercel&logoColor=white"></a> <a href="https://github.com/sponsors/tamalCodes"><img alt="Sponsor Tamal" src="https://img.shields.io/badge/sponsor-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#white"></a>
<a href="https://api.ngoworld.org/"><img alt="C" src="https://img.shields.io/badge/Production%20Release-07C160?style=for-the-badge&logo=vercel&logoColor=white"></a> <a href="https://github.com/sponsors/tamalCodes"><img alt="Sponsor Tamal" src="https://img.shields.io/badge/sponsor-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#white"></a>



</div>

<img alt="Milan Readme Banner" src="./docs/pictures/MilanBanner.png" width="700px"/>

</div>

<br>
Expand All @@ -32,7 +32,7 @@ Milan is a hub to **connect** NGOs, Charities, and the world to **collaborate**
<a href="https://opensource.guide/how-to-contribute/"><img alt="C" src="https://img.shields.io/badge/Open%20Source-%23F05032.svg?style=for-the-badge&logo=open-source-initiative&logoColor=white"></a>
<a href="https://docs.github.com/en/actions"><img alt="C" src="https://img.shields.io/badge/GitHub%20Actions-%232671E5.svg?style=for-the-badge&logo=github-actions&logoColor=white"></a>
<a href="https://docs.github.com/en/actions"><img alt="C" src="https://img.shields.io/badge/Razorpay-02042B?style=for-the-badge&logo=razorpay&logoColor=3395FF"></a>

</p>

</br>
Expand Down
32 changes: 32 additions & 0 deletions routes/club/Club.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* eslint-disable no-unused-vars */
const express = require("express");
const User = require("../../schema/user/UserSchema");
const { STATUSCODE, STATUSMESSAGE } = require("../../static/Status");
const router = express.Router();
const jwt = require("jsonwebtoken");
const UserSchema = require("../../schema/user/UserSchema");

router.get("/", async (req, res) => {
try {
Expand All @@ -28,4 +31,33 @@ router.get("/", async (req, res) => {
}
});

router.get("/dashboard", async (req, res) => {
try {
const token = req.cookies.Token;

if (!token) {
return res
.status(STATUSCODE.FORBIDDEN)
.json({ message: STATUSMESSAGE.FORBIDDEN });
}

const { User } = jwt.verify(token, process.env.JWT_SECRET);
const data = await UserSchema.findOne({ email: User.id });

if (!data)
return res
.status(STATUSCODE.NOT_FOUND)
.json({ message: STATUSMESSAGE.DASHBOARD_FETCH_FAILED });

const { password, _id, __v, ...dataWithoutSensitiveInfo } = data.toObject();
const dashboardData = { ...dataWithoutSensitiveInfo };

return res.status(STATUSCODE.OK).json(dashboardData);
} catch (error) {
res
.status(STATUSCODE.INTERNAL_SERVER_ERROR)
.json({ message: STATUSMESSAGE.INTERNAL_SERVER_ERROR });
}
});

module.exports = router;
1 change: 1 addition & 0 deletions static/Status.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const STATUSMESSAGE = {
SIGNUP_SUCCESS: "Signed up !",
SIGNUP_FAILED: "Signup failed !",
USER_NOT_FOUND: "User not found !",
DASHBOARD_FETCH_FAILED: "Failed to fetch dashboard data !",
USER_ALREADY_EXISTS: "User already exists, please Login !",
INVALID_CREDENTIALS: "Invalid credentials !",
INTERNAL_SERVER_ERROR: "Internal server error, try again later !",
Expand Down

0 comments on commit 1619bf8

Please sign in to comment.