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:
2026-01-05 17:31:52 +00:00
parent a4de80b98d
commit 69a7827b34
5 changed files with 24 additions and 68 deletions

View File

@@ -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" });