@20syldev/api 4.8.0 → 4.9.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 (109) hide show
  1. package/README.md +84 -47
  2. package/package.json +2 -1
  3. package/.github/FUNDING.yml +0 -1
  4. package/.prettierrc +0 -7
  5. package/eslint.config.js +0 -24
  6. package/robots.txt +0 -74
  7. package/src/app.ts +0 -53
  8. package/src/config/env.ts +0 -87
  9. package/src/config/plans.ts +0 -61
  10. package/src/config/versions.ts +0 -121
  11. package/src/constants.ts +0 -61
  12. package/src/favicon.ico +0 -0
  13. package/src/middleware/cors.ts +0 -23
  14. package/src/middleware/error.ts +0 -16
  15. package/src/middleware/json.ts +0 -9
  16. package/src/middleware/logger.ts +0 -32
  17. package/src/middleware/ratelimit.ts +0 -89
  18. package/src/middleware/version.ts +0 -40
  19. package/src/modules/v3/algorithms.js +0 -218
  20. package/src/modules/v3/captcha.js +0 -60
  21. package/src/modules/v3/chat.js +0 -111
  22. package/src/modules/v3/color.js +0 -60
  23. package/src/modules/v3/convert.js +0 -39
  24. package/src/modules/v3/domain.js +0 -86
  25. package/src/modules/v3/hash.js +0 -16
  26. package/src/modules/v3/hyperplanning.js +0 -56
  27. package/src/modules/v3/levenshtein.js +0 -46
  28. package/src/modules/v3/personal.js +0 -139
  29. package/src/modules/v3/qrcode.js +0 -20
  30. package/src/modules/v3/tic_tac_toe.js +0 -242
  31. package/src/modules/v3/time.js +0 -98
  32. package/src/modules/v3/token.js +0 -54
  33. package/src/modules/v3/username.js +0 -94
  34. package/src/modules/v3/utils.js +0 -77
  35. package/src/modules/v3.js +0 -15
  36. package/src/modules/v4/address.ts +0 -412
  37. package/src/modules/v4/agent.ts +0 -104
  38. package/src/modules/v4/algorithms.ts +0 -276
  39. package/src/modules/v4/captcha.ts +0 -114
  40. package/src/modules/v4/chat.ts +0 -130
  41. package/src/modules/v4/color.ts +0 -75
  42. package/src/modules/v4/convert.ts +0 -127
  43. package/src/modules/v4/cron.ts +0 -221
  44. package/src/modules/v4/dice.ts +0 -46
  45. package/src/modules/v4/domain.ts +0 -86
  46. package/src/modules/v4/encode.ts +0 -241
  47. package/src/modules/v4/geo.ts +0 -64
  48. package/src/modules/v4/hash.ts +0 -32
  49. package/src/modules/v4/hyperplanning.ts +0 -93
  50. package/src/modules/v4/ip.ts +0 -134
  51. package/src/modules/v4/levenshtein.ts +0 -46
  52. package/src/modules/v4/palette.ts +0 -71
  53. package/src/modules/v4/password.ts +0 -379
  54. package/src/modules/v4/personal.ts +0 -140
  55. package/src/modules/v4/placeholder.ts +0 -197
  56. package/src/modules/v4/qrcode.ts +0 -121
  57. package/src/modules/v4/regex.ts +0 -67
  58. package/src/modules/v4/statistics.ts +0 -62
  59. package/src/modules/v4/text.ts +0 -330
  60. package/src/modules/v4/tic_tac_toe.ts +0 -264
  61. package/src/modules/v4/time.ts +0 -149
  62. package/src/modules/v4/token.ts +0 -53
  63. package/src/modules/v4/username.ts +0 -94
  64. package/src/modules/v4/validate.ts +0 -76
  65. package/src/modules/v4.ts +0 -29
  66. package/src/routes/delete.ts +0 -72
  67. package/src/routes/get.ts +0 -856
  68. package/src/routes/index.ts +0 -59
  69. package/src/routes/patch.ts +0 -45
  70. package/src/routes/post.ts +0 -209
  71. package/src/storage/index.ts +0 -16
  72. package/src/types/express.d.ts +0 -17
  73. package/src/types/storage.ts +0 -48
  74. package/src/utils/colors.ts +0 -91
  75. package/src/utils/helpers.ts +0 -90
  76. package/src/utils/response.ts +0 -28
  77. package/tests/integration/api.test.ts +0 -772
  78. package/tests/tsconfig.json +0 -3
  79. package/tests/unit/address.test.ts +0 -84
  80. package/tests/unit/agent.test.ts +0 -113
  81. package/tests/unit/algorithms.test.ts +0 -121
  82. package/tests/unit/captcha.test.ts +0 -62
  83. package/tests/unit/chat.test.ts +0 -54
  84. package/tests/unit/color.test.ts +0 -54
  85. package/tests/unit/convert.test.ts +0 -68
  86. package/tests/unit/cron.test.ts +0 -110
  87. package/tests/unit/dice.test.ts +0 -58
  88. package/tests/unit/domain.test.ts +0 -48
  89. package/tests/unit/encode.test.ts +0 -109
  90. package/tests/unit/geo.test.ts +0 -46
  91. package/tests/unit/hash.test.ts +0 -45
  92. package/tests/unit/hyperplanning.test.ts +0 -97
  93. package/tests/unit/ip.test.ts +0 -140
  94. package/tests/unit/levenshtein.test.ts +0 -35
  95. package/tests/unit/palette.test.ts +0 -54
  96. package/tests/unit/password.test.ts +0 -86
  97. package/tests/unit/personal.test.ts +0 -66
  98. package/tests/unit/placeholder.test.ts +0 -58
  99. package/tests/unit/qrcode.test.ts +0 -83
  100. package/tests/unit/regex.test.ts +0 -95
  101. package/tests/unit/statistics.test.ts +0 -58
  102. package/tests/unit/text.test.ts +0 -108
  103. package/tests/unit/tic_tac_toe.test.ts +0 -56
  104. package/tests/unit/time.test.ts +0 -115
  105. package/tests/unit/token.test.ts +0 -62
  106. package/tests/unit/username.test.ts +0 -35
  107. package/tests/unit/validate.test.ts +0 -72
  108. package/tsconfig.json +0 -17
  109. package/tsconfig.test.json +0 -9
@@ -1,115 +0,0 @@
1
- import { strict as assert } from 'node:assert';
2
- import { describe, test } from 'node:test';
3
-
4
- import time from '../../src/modules/v4/time.js';
5
-
6
- describe('time', () => {
7
- test('live returns full set of formats', () => {
8
- const result = time('live');
9
- const fields = [
10
- 'iso',
11
- 'utc',
12
- 'timestamp',
13
- 'locale',
14
- 'date',
15
- 'time',
16
- 'year',
17
- 'month',
18
- 'day',
19
- 'hour',
20
- 'minute',
21
- 'second',
22
- 'ms',
23
- 'dayOfWeek',
24
- 'dayOfYear',
25
- 'weekNumber',
26
- 'timezone',
27
- 'timezoneOffset',
28
- ];
29
- for (const f of fields) {
30
- assert.ok(f in result, `missing field: ${f}`);
31
- }
32
- });
33
-
34
- test('iso is parseable', () => {
35
- const result = time('live');
36
- assert.ok(!isNaN(Date.parse(result.iso as string)));
37
- });
38
-
39
- test('format=year returns only date', () => {
40
- const result = time('live', undefined, undefined, 'year');
41
- assert.ok('date' in result);
42
- assert.equal(typeof result.date, 'number');
43
- });
44
-
45
- test('random within range', () => {
46
- const result = time('random', '2020-01-01', '2020-12-31');
47
- const ts = result.timestamp as number;
48
- assert.ok(ts >= new Date('2020-01-01').getTime());
49
- assert.ok(ts <= new Date('2020-12-31').getTime());
50
- });
51
-
52
- test('throws on invalid type', () => {
53
- assert.throws(() => time('foo'), /valid type/);
54
- });
55
-
56
- test('throws on invalid format', () => {
57
- assert.throws(() => time('live', undefined, undefined, 'fakeformat'), /valid format/);
58
- });
59
-
60
- test('throws on invalid timezone', () => {
61
- assert.throws(() => time('live', undefined, undefined, undefined, 'Mars/Olympus'), /valid timezone/);
62
- });
63
-
64
- test('Europe/Paris timezone', () => {
65
- const result = time('live', undefined, undefined, undefined, 'Europe/Paris');
66
- assert.equal(result.timezone, 'Europe/Paris');
67
- });
68
-
69
- describe('countdown', () => {
70
- test('future date returns direction future', () => {
71
- const future = new Date(Date.now() + 7 * 24 * 3600 * 1000).toISOString();
72
- const r = time('countdown', undefined, undefined, undefined, undefined, future);
73
- assert.equal(r.direction, 'future');
74
- });
75
-
76
- test('past date returns direction past', () => {
77
- const past = new Date(Date.now() - 7 * 24 * 3600 * 1000).toISOString();
78
- const r = time('countdown', undefined, undefined, undefined, undefined, past);
79
- assert.equal(r.direction, 'past');
80
- });
81
-
82
- test('remaining breakdown is correct', () => {
83
- const target = new Date(Date.now() + 2 * 86400 * 1000 + 3 * 3600 * 1000).toISOString();
84
- const r = time('countdown', undefined, undefined, undefined, undefined, target);
85
- const rem = r.remaining as { days: number; hours: number };
86
- assert.equal(rem.days, 2);
87
- assert.equal(rem.hours, 3);
88
- });
89
-
90
- test('human skips zero units', () => {
91
- const target = new Date(Date.now() + 3 * 86400 * 1000).toISOString();
92
- const r = time('countdown', undefined, undefined, undefined, undefined, target);
93
- assert.ok(!(r.human as string).includes('hour'));
94
- assert.ok(!(r.human as string).includes('minute'));
95
- });
96
-
97
- test('throws on missing target', () => {
98
- assert.throws(() => time('countdown'), /target date/);
99
- });
100
-
101
- test('throws on invalid target', () => {
102
- assert.throws(
103
- () => time('countdown', undefined, undefined, undefined, undefined, 'not-a-date'),
104
- /valid target date/,
105
- );
106
- });
107
-
108
- test('throws if target is more than 100 years away', () => {
109
- assert.throws(
110
- () => time('countdown', undefined, undefined, undefined, undefined, '2200-01-01'),
111
- /100 years/,
112
- );
113
- });
114
- });
115
- });
@@ -1,62 +0,0 @@
1
- import { strict as assert } from 'node:assert';
2
- import { describe, test } from 'node:test';
3
-
4
- import token from '../../src/modules/v4/token.js';
5
-
6
- describe('token', () => {
7
- test('alpha length', () => {
8
- const t = token(24, 'alpha');
9
- assert.equal(t.length, 24);
10
- assert.match(t, /^[a-zA-Z]+$/);
11
- });
12
-
13
- test('alphanum length', () => {
14
- const t = token(32, 'alphanum');
15
- assert.equal(t.length, 32);
16
- assert.match(t, /^[a-zA-Z0-9]+$/);
17
- });
18
-
19
- test('hex contains only hex chars', () => {
20
- const t = token(16, 'hex');
21
- assert.equal(t.length, 16);
22
- assert.match(t, /^[0-9a-f]+$/);
23
- });
24
-
25
- test('num contains only digits', () => {
26
- const t = token(20, 'num');
27
- assert.match(t, /^\d+$/);
28
- });
29
-
30
- test('urlsafe chars only', () => {
31
- const t = token(40, 'urlsafe');
32
- assert.match(t, /^[a-zA-Z0-9_-]+$/);
33
- });
34
-
35
- test('uuid type produces hex', () => {
36
- const t = token(32, 'uuid');
37
- assert.equal(t.length, 32);
38
- });
39
-
40
- test('default type alphanum', () => {
41
- const t = token(20);
42
- assert.match(t, /^[a-zA-Z0-9]+$/);
43
- });
44
-
45
- test('throws below minimum length', () => {
46
- assert.throws(() => token(5, 'alpha'), /greater than or equal to 12/);
47
- });
48
-
49
- test('throws above maximum length', () => {
50
- assert.throws(() => token(5000, 'alpha'), /4096/);
51
- });
52
-
53
- test('throws on invalid type', () => {
54
- assert.throws(() => token(20, 'martian'), /Invalid token type/);
55
- });
56
-
57
- test('two tokens are different (entropy check)', () => {
58
- const a = token(32, 'alphanum');
59
- const b = token(32, 'alphanum');
60
- assert.notEqual(a, b);
61
- });
62
- });
@@ -1,35 +0,0 @@
1
- import { strict as assert } from 'node:assert';
2
- import { describe, test } from 'node:test';
3
-
4
- import username from '../../src/modules/v4/username.js';
5
-
6
- describe('username', () => {
7
- test('returns expected fields', () => {
8
- const result = username();
9
- assert.ok('username' in result);
10
- assert.ok('number' in result);
11
- assert.ok('adjective' in result);
12
- assert.ok('animal' in result);
13
- assert.ok('job' in result);
14
- });
15
-
16
- test('username is a non-empty string', () => {
17
- const result = username();
18
- assert.equal(typeof result.username, 'string');
19
- assert.ok((result.username as string).length > 0);
20
- });
21
-
22
- test('number is between 0 and 99', () => {
23
- const result = username();
24
- const n = result.number as number;
25
- assert.ok(n >= 0 && n <= 99);
26
- });
27
-
28
- test('produces varied usernames', () => {
29
- const seen = new Set<string>();
30
- for (let i = 0; i < 10; i++) {
31
- seen.add(username().username as string);
32
- }
33
- assert.ok(seen.size > 1);
34
- });
35
- });
@@ -1,72 +0,0 @@
1
- import { strict as assert } from 'node:assert';
2
- import { describe, test } from 'node:test';
3
-
4
- import { email, iban, luhn } from '../../src/modules/v4/validate.js';
5
-
6
- describe('validate', () => {
7
- describe('luhn', () => {
8
- test('valid Visa test card', () => {
9
- const result = luhn('4111111111111111');
10
- assert.equal(result.valid, true);
11
- });
12
-
13
- test('invalid card number', () => {
14
- const result = luhn('4111111111111112');
15
- assert.equal(result.valid, false);
16
- });
17
-
18
- test('strips spaces and dashes', () => {
19
- const result = luhn('4111-1111 1111-1111');
20
- assert.equal(result.valid, true);
21
- assert.equal(result.value, '4111111111111111');
22
- });
23
-
24
- test('throws on non-digit', () => {
25
- assert.throws(() => luhn('4111ABC11111111'), /only digits/);
26
- });
27
-
28
- test('throws on too short', () => {
29
- assert.throws(() => luhn('411111'), /between 12 and 19/);
30
- });
31
- });
32
-
33
- describe('iban', () => {
34
- test('valid French IBAN', () => {
35
- const result = iban('FR1420041010050500013M02606');
36
- assert.equal(result.valid, true);
37
- assert.equal(result.country, 'FR');
38
- });
39
-
40
- test('invalid checksum', () => {
41
- const result = iban('FR1420041010050500013M02607');
42
- assert.equal(result.valid, false);
43
- });
44
-
45
- test('strips spaces', () => {
46
- const result = iban('FR14 2004 1010 0505 0001 3M02 606');
47
- assert.equal(result.valid, true);
48
- });
49
-
50
- test('throws on bad format', () => {
51
- assert.throws(() => iban('1234'), /Invalid IBAN format/);
52
- });
53
- });
54
-
55
- describe('email', () => {
56
- test('valid email', () => {
57
- assert.equal(email('hello@example.com').valid, true);
58
- });
59
-
60
- test('rejects missing domain', () => {
61
- assert.equal(email('hello@').valid, false);
62
- });
63
-
64
- test('rejects missing @', () => {
65
- assert.equal(email('helloexample.com').valid, false);
66
- });
67
-
68
- test('rejects spaces', () => {
69
- assert.equal(email('hello world@example.com').valid, false);
70
- });
71
- });
72
- });
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "allowJs": true,
7
- "strict": true,
8
- "noUncheckedIndexedAccess": true,
9
- "outDir": "dist",
10
- "rootDir": "src",
11
- "declaration": false,
12
- "sourceMap": true,
13
- "esModuleInterop": true,
14
- "skipLibCheck": true
15
- },
16
- "include": ["src"]
17
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": ".",
5
- "noEmit": true,
6
- "types": ["node"]
7
- },
8
- "include": ["src", "tests"]
9
- }