1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 00:25:17 +00:00

Ready to implement API limit

This commit is contained in:
2020-03-25 09:04:04 +01:00
parent d6b5393fe4
commit 78a612048d
3 changed files with 79 additions and 9 deletions

View File

@ -0,0 +1,39 @@
/**
* API Limits helper
*
* This implementation of API limits stores
* the counters inside memory, not in the databas
*
* @author Pierre HUBERT
*/
// Different supported actions
export enum Action {
LOGIN_FAILED = "login_failed",
CREATE_ACCOUNT = "create_account"
}
export class APILimitHelper {
/**
* Trigger the counter (increase it by one)
*
* @param ip Target IP address
* @param action The action to check
*/
public static async Trigger(ip: string, action: Action) {
// TODO : trigger counter
}
/**
* Count the number of actions perfomed by a user
*
* @param ip Target IP address
* @param action The action to check
*/
public static async Count(ip: string, action: Action) : Promise<number> {
// TODO : return count
return 0;
}
}