-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
seguridad en server Cross-Site Scripting (XSS)-
- Loading branch information
Showing
3 changed files
with
208 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
import express from 'express'; | ||
import {getAllTables} from '../controllers/tableController.js'; | ||
import { createTable, checkTableExists, getAllTables, dropTable, updateTable,getTablesAndColumns } from '../controllers/tableController.js'; | ||
import rateLimit from 'express-rate-limit'; | ||
|
||
const router = express.Router(); | ||
|
||
// Configura el limitador de velocidad para rutas sensibles | ||
const sensitiveRouteLimiter = rateLimit({ | ||
windowMs: 15 * 60 * 1000, // 15 minutos | ||
max: 50, // máximo 50 solicitudes por ventana de tiempo | ||
message: 'Too many requests from this IP, please try again after 15 minutes' // mensaje de error personalizado | ||
}); | ||
|
||
// Configura el limitador de velocidad general (si decides usarlo) | ||
const generalLimiter = rateLimit({ | ||
windowMs: 15 * 60 * 1000, // 15 minutos | ||
max: 100, // máximo 100 solicitudes por ventana de tiempo | ||
message: 'Too many requests from this IP, please try again after 15 minutes' // mensaje de error personalizado | ||
}); | ||
|
||
// Ruta para crear una tabla con columnas definidas en el cuerpo de la solicitud | ||
router.post('/create-table', sensitiveRouteLimiter,createTable); | ||
|
||
// Ruta para verificar si una tabla existe | ||
router.get('/check-table/:tableName', generalLimiter, checkTableExists); | ||
|
||
// Ruta para obtener todos los nombres de las tablas | ||
router.get('/get-tables', generalLimiter,getAllTables); | ||
|
||
// Ruta para eliminar una tabla | ||
router.delete('/drop-table/:tableName',sensitiveRouteLimiter, dropTable); | ||
|
||
// Ruta para actualizar una tabla | ||
router.put('/update-table/:tableName',sensitiveRouteLimiter, updateTable); | ||
|
||
router.get('/get-tables-columns',generalLimiter, getTablesAndColumns); | ||
|
||
export default router; |