revert 377971411a
revert feat(api): merkezi rate limiting sistemi ekle Yeni rate-limiter middleware modülü oluşturuldu. loginLimiter (5 istek/dakika), apiLimiter (30 istek/dakika) ve uploadLimiter (10 istek/dakika) tanımlandı. Auth, loop, timer ve torrent rotalarına rate limiting uygulandı. Torrent rotalarında SHA-1 hash validasyonu eklendi.
This commit is contained in:
@@ -10,11 +10,10 @@ import { config } from "../config";
|
||||
import { setArchiveStatus } from "../torrent/torrent.archive";
|
||||
import { nowIso } from "../utils/time";
|
||||
import { readLoopLogs } from "../storage/loopLogs";
|
||||
import { apiLimiter } from "../middleware/rate-limiter";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.post("/start", apiLimiter, async (req, res) => {
|
||||
router.post("/start", async (req, res) => {
|
||||
const parsed = loopStartSchema.safeParse(req.body);
|
||||
if (!parsed.success) {
|
||||
return res.status(400).json({ error: parsed.error.flatten() });
|
||||
@@ -71,7 +70,7 @@ router.post("/start", apiLimiter, async (req, res) => {
|
||||
res.json(job);
|
||||
});
|
||||
|
||||
router.post("/stop/:jobId", apiLimiter, async (req, res) => {
|
||||
router.post("/stop/:jobId", async (req, res) => {
|
||||
const { jobId } = req.params;
|
||||
const job = await stopLoopJob(jobId);
|
||||
if (!job) {
|
||||
@@ -86,7 +85,7 @@ router.post("/stop/:jobId", apiLimiter, async (req, res) => {
|
||||
res.json(job);
|
||||
});
|
||||
|
||||
router.post("/stop-by-hash", apiLimiter, async (req, res) => {
|
||||
router.post("/stop-by-hash", async (req, res) => {
|
||||
const { hash } = req.body ?? {};
|
||||
if (!hash) {
|
||||
return res.status(400).json({ error: "Missing hash" });
|
||||
|
||||
Reference in New Issue
Block a user