@20syldev/api 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +3 -3
  2. package/dist/config/versions.js +10 -0
  3. package/dist/config/versions.js.map +1 -1
  4. package/dist/constants.js +0 -2
  5. package/dist/constants.js.map +1 -1
  6. package/dist/modules/v3/chat.js +1 -1
  7. package/dist/modules/v3/chat.js.map +1 -1
  8. package/dist/modules/v3/domain.js +1 -1
  9. package/dist/modules/v3/domain.js.map +1 -1
  10. package/dist/modules/v3/hyperplanning.js +1 -1
  11. package/dist/modules/v3/hyperplanning.js.map +1 -1
  12. package/dist/modules/v3/personal.js +1 -1
  13. package/dist/modules/v3/personal.js.map +1 -1
  14. package/dist/modules/v3/username.js +1 -1
  15. package/dist/modules/v3/username.js.map +1 -1
  16. package/dist/modules/v4/captcha.js +60 -23
  17. package/dist/modules/v4/captcha.js.map +1 -1
  18. package/dist/modules/v4/chat.js +1 -1
  19. package/dist/modules/v4/chat.js.map +1 -1
  20. package/dist/modules/v4/color.js +44 -35
  21. package/dist/modules/v4/color.js.map +1 -1
  22. package/dist/modules/v4/colors.js +54 -0
  23. package/dist/modules/v4/colors.js.map +1 -0
  24. package/dist/modules/v4/convert.js +93 -19
  25. package/dist/modules/v4/convert.js.map +1 -1
  26. package/dist/modules/v4/domain.js +1 -1
  27. package/dist/modules/v4/domain.js.map +1 -1
  28. package/dist/modules/v4/hash.js +11 -4
  29. package/dist/modules/v4/hash.js.map +1 -1
  30. package/dist/modules/v4/hyperplanning.js +1 -1
  31. package/dist/modules/v4/hyperplanning.js.map +1 -1
  32. package/dist/modules/v4/palette.js +2 -43
  33. package/dist/modules/v4/palette.js.map +1 -1
  34. package/dist/modules/v4/personal.js +1 -1
  35. package/dist/modules/v4/personal.js.map +1 -1
  36. package/dist/modules/v4/placeholder.js +5 -10
  37. package/dist/modules/v4/placeholder.js.map +1 -1
  38. package/dist/modules/v4/qrcode.js +79 -6
  39. package/dist/modules/v4/qrcode.js.map +1 -1
  40. package/dist/modules/v4/username.js +1 -1
  41. package/dist/modules/v4/username.js.map +1 -1
  42. package/dist/routes/delete.js +14 -14
  43. package/dist/routes/delete.js.map +1 -1
  44. package/dist/routes/get.js +68 -13
  45. package/dist/routes/get.js.map +1 -1
  46. package/dist/routes/post.js +10 -3
  47. package/dist/routes/post.js.map +1 -1
  48. package/dist/utils/colors.js +54 -0
  49. package/dist/utils/colors.js.map +1 -0
  50. package/dist/utils/helpers.js +26 -0
  51. package/dist/utils/helpers.js.map +1 -0
  52. package/package.json +1 -1
  53. package/src/config/versions.ts +10 -0
  54. package/src/constants.ts +0 -2
  55. package/src/modules/v4/captcha.ts +84 -27
  56. package/src/modules/v4/chat.ts +1 -1
  57. package/src/modules/v4/color.ts +56 -52
  58. package/src/modules/v4/convert.ts +100 -20
  59. package/src/modules/v4/domain.ts +1 -1
  60. package/src/modules/v4/hash.ts +18 -4
  61. package/src/modules/v4/hyperplanning.ts +1 -1
  62. package/src/modules/v4/palette.ts +3 -43
  63. package/src/modules/v4/personal.ts +1 -1
  64. package/src/modules/v4/placeholder.ts +6 -9
  65. package/src/modules/v4/qrcode.ts +108 -6
  66. package/src/modules/v4/username.ts +1 -1
  67. package/src/routes/get.ts +71 -15
  68. package/src/routes/post.ts +11 -3
  69. package/src/utils/colors.ts +91 -0
  70. package/src/utils/helpers.ts +90 -0
  71. package/src/utils/response.ts +8 -0
  72. package/tests/integration/api.test.ts +51 -7
  73. package/tests/unit/captcha.test.ts +50 -12
  74. package/tests/unit/chat.test.ts +4 -1
  75. package/tests/unit/color.test.ts +24 -4
  76. package/tests/unit/convert.test.ts +26 -1
  77. package/tests/unit/hash.test.ts +17 -10
  78. package/tests/unit/qrcode.test.ts +72 -4
  79. package/tests/unit/tic_tac_toe.test.ts +4 -1
  80. package/src/modules/v4/utils.ts +0 -38
@@ -1,38 +0,0 @@
1
- export function random<T>(arr: T[]): T {
2
- return arr[Math.floor(Math.random() * arr.length)]!;
3
- }
4
-
5
- export function randomNumber(min: number, max: number): number {
6
- return Math.floor(Math.random() * (max - min + 1)) + min;
7
- }
8
-
9
- export function genIP(): string {
10
- return `${randomNumber(0, 255)}.${randomNumber(0, 255)}.${randomNumber(0, 255)}.${randomNumber(0, 255)}`;
11
- }
12
-
13
- export function formatDate(date: Date): string {
14
- return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toISOString().replace('Z', '');
15
- }
16
-
17
- export function envList(key: string): string[] | null {
18
- const v = process.env[key];
19
- return v && v !== 'undefined' ? v.split(' ') : null;
20
- }
21
-
22
- export function checkRateLimit(
23
- rateLimits: Record<string, number[]>,
24
- userId: string,
25
- timestamp: number,
26
- window = 10000,
27
- limit = 50,
28
- ): boolean {
29
- rateLimits[userId] = (rateLimits[userId] ?? []).filter((ts) => timestamp - ts < window);
30
-
31
- if (rateLimits[userId]!.length > limit) {
32
- const remainingTime = Math.ceil((rateLimits[userId]![0]! + window - timestamp) / 1000);
33
- throw new Error(`Rate limit exceeded. Try again in ${remainingTime} seconds.`);
34
- }
35
-
36
- rateLimits[userId]!.push(timestamp);
37
- return false;
38
- }