Allow custom ratelimits

This commit is contained in:
Aaron Dewes 2021-04-29 16:31:13 +02:00 committed by GitHub
parent 1c4eb6d83a
commit b9a55f01d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,6 @@
let config = {
postRateLimit: 100,
rateLimit: 200,
bitcoind: {
rpc: 'http://login:password@1.1.1.1:8332/wallet/wallet.dat',
},

View File

@ -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) {

View File

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