diff --git a/backend/src/index.js b/backend/src/index.js index 7d02202..24918f3 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -17,7 +17,7 @@ const limiter = rateLimit({ sendCommand: (...args) => redis.call(...args) }), windowMs: 15 * 60 * 1000, // 15 minutes - max: 100, // limiting each IP to 50 requests per windowMs + max: 2000, // limiting each IP to 50 requests per windowMs standardHeaders: true, legacyHeaders: false, keyGenerator: (req) => { diff --git a/backend/src/services/flashcard.services.js b/backend/src/services/flashcard.services.js index 29704a0..8e9a822 100644 --- a/backend/src/services/flashcard.services.js +++ b/backend/src/services/flashcard.services.js @@ -9,8 +9,12 @@ const redis = require("../config/redis.config"); class FlashcardServices { // create a new Flashcard async createFlashcard(data) { + // using transaction to make sure that both the pack and flashcard are created together const t = await sequelize.transaction(); try { + + /* Todo: update this to use bulk insert instead */ + const [pack, created] = await Pack.findOrCreate({ where: { name: data.packName.trim() }, defaults: { name: data.packName.trim() },