-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #364 from The-Purple-Warehouse/main
[staging deploy] Add team management page
- Loading branch information
Showing
18 changed files
with
7,430 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ node_modules/ | |
build/ | ||
.idea/ | ||
config/secret.json | ||
**/accuracy.ts | ||
**/accuracy.ts | ||
**/adminHelpers.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { RateLimit, Stores } from 'koa2-ratelimit'; | ||
import mongoose from "../db"; | ||
|
||
import { retrieveRateLimit } from "../helpers/apiKey" | ||
|
||
const mongo = new Stores.Mongodb(mongoose.connection, { | ||
collectionName: 'ratelimits', | ||
collectionAbuseName: 'ratelimitsabuses', | ||
}); | ||
|
||
export const rateLimiter = RateLimit.middleware({ | ||
interval: { sec: 1 }, // 1 second | ||
max: async (ctx) => { | ||
const apiKey = ctx.query.key; | ||
const rateInfo = await retrieveRateLimit(apiKey); | ||
return rateInfo.rateLimit; // max requests per second per team | ||
}, | ||
keyGenerator: async (ctx) => { | ||
const apiKey = ctx.query.key; | ||
const rateInfo = await retrieveRateLimit(apiKey); | ||
return `teamid:${rateInfo.teamNumber}`; // team number as key | ||
}, | ||
store: mongo, | ||
message: "Exceeded the rate limit. Try again later." | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.