Skip to content

Commit

Permalink
Add GET server endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinaisslaying committed Apr 14, 2020
1 parent cf2bbc4 commit fc21556
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Routes/v1-REVISED.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const apiRateSettings = new rateLimit.RateLimiterRedis({
points: 75,
duration: 1,
blockDuration: 10,
keyPrefix: "delAPIRatelimit"
keyPrefix: "ratelimiter"
});

router.get('*', async (req, res, next) => {
Expand Down Expand Up @@ -115,6 +115,18 @@ router.get("/user/:id", async (req, res) => {
res.status(200).json({ error: false, status: 200, user });
});

router.get("/server/:id", async (req, res) => {
const server = await req.app.db.collection("servers").findOne({ "id": req.params.id }, { projection: { _id: 0, links: 0 } });

if (!server) return res.status(404).json({
error: true,
message: "Unknown Server",
status: 404
});

res.status(200).json({ error: false, status: 200, server });
});

router.get("/bot/:id", async (req, res) => {
const bot = await req.app.db.collection("bots").findOne({ id: req.params.id }, { projection: { _id: 0, token: 0, modNotes: 0, votes: 0, "status.pendingVerification": 0 } });

Expand Down

2 comments on commit fc21556

@Connor200024
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice API ;)

@carolinaisslaying
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice API ;)

I wish I could lul emote here lmfao.

Please sign in to comment.