const express = require('express');
const rateLimit = require('express-rate-limit');
const app = express();
// Create a rate limiter middleware
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
message: 'Too many requests, please try again later.',
standardHeaders: true, // Return the rate-limit headers
legacyHeaders: false, // Disable the X-RateLimit-* headers
});
// Apply to all requests
app.use(limiter);
// ... rest of your API routes