defaultApiRateLimitConfig.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { IApiRateLimitConfig } from '../../interfaces/api-rate-limit-config';
  2. // strict config
  3. const defaultStrictMaxRequests = 1; // per second
  4. const defaultStrictConfig: IApiRateLimitConfig = {
  5. '/login/activateInvited': {
  6. method: 'POST',
  7. maxRequests: defaultStrictMaxRequests,
  8. },
  9. '/login': {
  10. method: 'POST',
  11. maxRequests: defaultStrictMaxRequests,
  12. },
  13. '/register': {
  14. method: 'POST',
  15. maxRequests: defaultStrictMaxRequests,
  16. },
  17. '/installer': {
  18. method: 'POST',
  19. maxRequests: defaultStrictMaxRequests,
  20. },
  21. '/_api/login/testLdap': {
  22. method: 'POST',
  23. maxRequests: defaultStrictMaxRequests,
  24. },
  25. '/user-activation/register': {
  26. method: 'POST',
  27. maxRequests: defaultStrictMaxRequests,
  28. },
  29. };
  30. // infinity config
  31. const defaultInfinityConfig: IApiRateLimitConfig = {
  32. '/_api/v3/healthcheck': {
  33. method: 'GET',
  34. maxRequests: Infinity,
  35. },
  36. };
  37. // default config without reg exp
  38. export const defaultConfig = { ...defaultStrictConfig, ...defaultInfinityConfig };
  39. // default config with reg exp
  40. export const defaultConfigWithRegExp = {
  41. '/forgot-password/.*': {
  42. method: 'GET',
  43. maxRequests: defaultStrictMaxRequests,
  44. },
  45. '/user-activation/.*': {
  46. method: 'GET',
  47. maxRequests: defaultStrictMaxRequests,
  48. },
  49. '/download/[0-9a-z]{24}': {
  50. method: 'GET',
  51. maxRequests: defaultStrictMaxRequests,
  52. },
  53. '/share/[0-9a-z]{24}': {
  54. method: 'GET',
  55. maxRequests: defaultStrictMaxRequests,
  56. },
  57. };