fix(#19): Implement rate limiting for auth and write-heavy endpoints
Some checks are pending
Docker Test / test (push) Waiting to run
Some checks are pending
Docker Test / test (push) Waiting to run
This commit is contained in:
parent
a0fc6fe236
commit
2b09cf05eb
3 changed files with 128 additions and 7 deletions
|
|
@ -8,6 +8,7 @@ import addressRoutes from './routes/addresses.js';
|
|||
import contactRoutes from './routes/contacts.js';
|
||||
import profileRoutes from './routes/profile.js';
|
||||
import logger from './middleware/logger.js';
|
||||
const { rateLimit, authRateLimit } = require('./middleware/rateLimit.js');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
|
|
@ -33,13 +34,16 @@ app.get('/metrics', (_req, res) => {
|
|||
});
|
||||
});
|
||||
|
||||
app.use('/auth', authRoutes);
|
||||
app.use('/requests', helpRequestRoutes);
|
||||
app.use('/offers', offerRoutes);
|
||||
app.use('/reviews', reviewRoutes);
|
||||
app.use('/addresses', addressRoutes);
|
||||
app.use('/contacts', contactRoutes);
|
||||
app.use('/profile', profileRoutes);
|
||||
// Rate limiting für Auth-Endpunkte
|
||||
app.use('/auth', authRateLimit(), authRoutes);
|
||||
|
||||
// Rate limiting für write-heavy Endpunkte
|
||||
app.use('/requests', rateLimit({ max: 50 }), helpRequestRoutes);
|
||||
app.use('/offers', rateLimit({ max: 50 }), offerRoutes);
|
||||
app.use('/reviews', rateLimit({ max: 50 }), reviewRoutes);
|
||||
app.use('/addresses', rateLimit({ max: 50 }), addressRoutes);
|
||||
app.use('/contacts', rateLimit({ max: 50 }), contactRoutes);
|
||||
app.use('/profile', rateLimit({ max: 50 }), profileRoutes);
|
||||
|
||||
const port = Number(process.env.PORT || 3000);
|
||||
app.listen(port, () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue