Skip to content

Commit

Permalink
Merge pull request #461 from AyushSharma72/rate
Browse files Browse the repository at this point in the history
added rate limit middleware
  • Loading branch information
dhairyagothi authored Oct 30, 2024
2 parents c366b49 + 5d92019 commit 1cf73ad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
16 changes: 16 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"depcheck": "^1.4.7",
"dotenv": "^16.4.5",
"express": "^4.21.1",
"express-rate-limit": "^7.4.1",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.7.0",
"node": "^22.8.0",
Expand Down
24 changes: 16 additions & 8 deletions backend/routes/authRoutes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import express from "express";
import rateLimit from "express-rate-limit";
import {
registerUser,
loginUser,
Expand All @@ -14,30 +15,37 @@ import { submitFeedback } from "../controllers/submitFeedback.js";

const router = express.Router();

const loginLimiter = rateLimit({
windowMs: 5 * 60 * 1000, // 55 minutes
max: 5, // Limit each IP to 5 requests per windowMs
message: "Too many login attempts from this IP, please try again later.",
});

// Register route
router.post("/register", registerUser);

// Login route
router.post("/login", loginUser);
// Login route with rate limiter
router.post("/login", loginLimiter, loginUser);

// Logout route
router.post("/logout", verifyJWT, logoutUser);

// Verify route
router.get("/verify", verifyUser);

// Feedback route
router.post("/feedback", verifyJWT, submitFeedback);

router.post("/feedback" , verifyJWT, submitFeedback)

//cloakroom bookings route
// Cloakroom bookings route
router.post("/bookCloakroom", verifyJWT, createCloakroomBooking);

//wheelchair bookings route
// Wheelchair bookings route
router.post("/bookWheelchair", verifyJWT, createWheelchairBooking);

//coolie bookings route
// Coolie bookings route
router.post("/bookCoolie", verifyJWT, createCoolieBooking);

// get all stations route
// Get all stations route
router.get("/all-stations", verifyJWT, sendStations);

export default router;

0 comments on commit 1cf73ad

Please sign in to comment.