diff --git a/config.js b/config.js index b8381a4..204e847 100644 --- a/config.js +++ b/config.js @@ -1,4 +1,6 @@ let config = { + postRateLimit: 100, + rateLimit: 200, bitcoind: { rpc: 'http://login:password@1.1.1.1:8332/wallet/wallet.dat', }, diff --git a/controllers/api.js b/controllers/api.js index d0ce5e1..ae8eb1d 100644 --- a/controllers/api.js +++ b/controllers/api.js @@ -126,7 +126,7 @@ setInterval(updateDescribeGraph, 120000); const rateLimit = require('express-rate-limit'); const postLimiter = rateLimit({ windowMs: 30 * 60 * 1000, - max: 100, + max: config.postRateLimit || 100, }); router.post('/create', postLimiter, async function (req, res) { diff --git a/index.js b/index.js index 01c0609..10334af 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ let express = require('express'); let morgan = require('morgan'); import { v4 as uuidv4 } from 'uuid'; let logger = require('./utils/logger'); +const config = require('./config'); morgan.token('id', function getId(req) { return req.id; @@ -19,7 +20,7 @@ app.enable('trust proxy'); const rateLimit = require('express-rate-limit'); const limiter = rateLimit({ windowMs: 15 * 60 * 1000, - max: 200, + max: config.rateLimit || 200, }); app.use(limiter);