Skip to content

Commit f3319ee

Browse files
authored
Merge branch 'main' into guidedButton
2 parents a2b89dc + a6e089b commit f3319ee

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

components/clp-package-utils/clp_package_utils/scripts/start_clp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ def start_webui(
937937
f"HOST={clp_config.webui.host}",
938938
f"PORT={clp_config.webui.port}",
939939
f"NODE_ENV=production",
940+
f"RATE_LIMIT={clp_config.webui.rate_limit}",
940941
]
941942
necessary_mounts = [
942943
mounts.clp_home,

components/clp-py-utils/clp_py_utils/clp_config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ class WebUi(BaseModel):
731731
host: str = "localhost"
732732
port: int = 4000
733733
results_metadata_collection_name: str = "results-metadata"
734+
rate_limit: int = 1000
734735

735736
@validator("host")
736737
def validate_host(cls, field):
@@ -750,6 +751,12 @@ def validate_results_metadata_collection_name(cls, field):
750751
)
751752
return field
752753

754+
@validator("rate_limit")
755+
def validate_rate_limit(cls, field):
756+
if field <= 0:
757+
raise ValueError(f"rate_limit must be greater than 0")
758+
return field
759+
753760

754761
class SweepInterval(BaseModel):
755762
archive: int = 60

components/package-template/src/etc/clp-config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
# host: "localhost"
6767
# port: 4000
6868
# results_metadata_collection_name: "results-metadata"
69+
# rate_limit: 1000
6970
#
7071
## Where archives should be output to
7172
#archive_output:

components/webui/server/.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
# Reference: https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production
44
NODE_ENV=production
55

6+
# Network
67
HOST=localhost
78
PORT=3000
9+
10+
# Database
811
CLP_DB_USER=clp-user
912
CLP_DB_PASS=
13+
14+
# Security
15+
RATE_LIMIT=1000

components/webui/server/src/plugins/external/env.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ declare module "fastify" {
99
HOST: string;
1010
CLP_DB_USER: string;
1111
CLP_DB_PASS: string;
12-
13-
RATE_LIMIT_MAX: number;
12+
RATE_LIMIT: number;
1413
};
1514
}
1615
}
@@ -25,6 +24,7 @@ const schema = {
2524
"CLP_DB_PASS",
2625
],
2726
properties: {
27+
// Network
2828
PORT: {
2929
type: "number",
3030
default: 3000,
@@ -48,9 +48,10 @@ const schema = {
4848
},
4949

5050
// Security
51-
RATE_LIMIT_MAX: {
51+
RATE_LIMIT: {
5252
type: "number",
53-
default: 100,
53+
default: 1_000,
54+
minimum: 1,
5455
},
5556
},
5657
};

components/webui/server/src/plugins/external/rateLimit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {FastifyInstance} from "fastify";
66

77
export const autoConfig = (fastify: FastifyInstance) => {
88
return {
9-
max: fastify.config.RATE_LIMIT_MAX,
9+
max: fastify.config.RATE_LIMIT,
1010
timeWindow: "1 minute",
1111
};
1212
};

0 commit comments

Comments
 (0)