Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TDT4240 Tank Wars
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Snorre Skjellestad Kristiansen
TDT4240 Tank Wars
Commits
370f2ab3
Commit
370f2ab3
authored
1 year ago
by
Fredrik Fonn Hansen
Browse files
Options
Downloads
Plain Diff
Merge branch 'backend-30-req' into 'main'
Backend 30 req See merge request
!61
parents
9b1da252
9690dd76
No related branches found
Branches containing commit
No related tags found
1 merge request
!61
Backend 30 req
Pipeline
#215562
failed with stages
in 5 minutes and 36 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+22
-0
22 additions, 0 deletions
.gitlab-ci.yml
backend/README.md
+1
-1
1 addition, 1 deletion
backend/README.md
backend/src/middleware/rateLimiter.ts
+1
-1
1 addition, 1 deletion
backend/src/middleware/rateLimiter.ts
with
24 additions
and
2 deletions
.gitlab-ci.yml
+
22
−
0
View file @
370f2ab3
...
...
@@ -111,3 +111,25 @@ Backend (NTNU-VM):
only
:
refs
:
-
main
VM Heartbeat
:
stage
:
deploy
needs
:
[
Backend (NTNU-VM)
]
image
:
alpine
script
:
-
apk add --no-cache curl
-
|
for i in {1..18}; do
sleep 10
response=$(curl --silent --write-out "%{http_code}" --connect-timeout 5 --max-time 10 http://10.212.26.72/server/heartbeat)
echo "Response: $response"
if [ "$response" -eq 200 ]; then
echo "Server is alive"
exit 0
fi
done
echo "Server did not respond with 200 OK after 3 minutes"
exit 1
only
:
refs
:
-
main
This diff is collapsed.
Click to expand it.
backend/README.md
+
1
−
1
View file @
370f2ab3
...
...
@@ -39,4 +39,4 @@ e2e tests: `yarn test`
## Restrictions
The backend will only allow
15
requests per minute from the same IP address. This is to prevent abuse of the API.
The backend will only allow
30
requests per minute from the same IP address. This is to prevent abuse of the API.
This diff is collapsed.
Click to expand it.
backend/src/middleware/rateLimiter.ts
+
1
−
1
View file @
370f2ab3
...
...
@@ -3,7 +3,7 @@ const rateLimit = require('express-rate-limit');
// Configure rate limiter
export
const
rateLimiter
=
rateLimit
({
windowMs
:
60
*
1000
,
// 1 minute in milliseconds
max
:
15
,
// Limit each IP to 1000 requests per windowMs
max
:
30
,
// Limit each IP to 1000 requests per windowMs
statusCode
:
429
,
// HTTP status code to send when rate limit is exceeded (Too Many Requests)
message
:
'
Too many requests, please try again later.
'
,
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment