mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
feat(server): expose the api rate limit to the env vars
This commit is contained in:
@@ -47,3 +47,6 @@ AGENDASH_AUTH_PASSWORD=123123
|
|||||||
SIGNUP_DISABLED=false
|
SIGNUP_DISABLED=false
|
||||||
SIGNUP_ALLOWED_DOMAINS=
|
SIGNUP_ALLOWED_DOMAINS=
|
||||||
SIGNUP_ALLOWED_EMAILS=
|
SIGNUP_ALLOWED_EMAILS=
|
||||||
|
|
||||||
|
# API rate limit (points,duration,block duration).
|
||||||
|
API_RATE_LIMIT=120,60,600
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { toInteger } from 'lodash';
|
||||||
import { castCommaListEnvVarToArray, parseBoolean } from '@/utils';
|
import { castCommaListEnvVarToArray, parseBoolean } from '@/utils';
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
const API_RATE_LIMIT = process.env.API_RATE_LIMIT?.split(',') || [];
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
/**
|
||||||
* Your favorite port
|
* Your favorite port
|
||||||
@@ -130,9 +133,9 @@ module.exports = {
|
|||||||
blockDuration: 60 * 15,
|
blockDuration: 60 * 15,
|
||||||
},
|
},
|
||||||
requests: {
|
requests: {
|
||||||
points: 60,
|
points: API_RATE_LIMIT[0] ? toInteger(API_RATE_LIMIT[0]) : 120,
|
||||||
duration: 60,
|
duration: API_RATE_LIMIT[1] ? toInteger(API_RATE_LIMIT[1]) : 60,
|
||||||
blockDuration: 60 * 10,
|
blockDuration: API_RATE_LIMIT[2] ? toInteger(API_RATE_LIMIT[2]) : 60 * 10,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user