@20syldev/api 5.6.0 → 5.8.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 (148) hide show
  1. package/.prettierignore +5 -0
  2. package/README.md +204 -80
  3. package/dist/app.d.ts +2 -0
  4. package/dist/config/env.d.ts +21 -0
  5. package/dist/config/env.js +10 -2
  6. package/dist/config/env.js.map +1 -1
  7. package/dist/config/plans.d.ts +26 -0
  8. package/dist/config/versions.d.ts +18 -0
  9. package/dist/config/versions.js +5 -0
  10. package/dist/config/versions.js.map +1 -1
  11. package/dist/constants.d.ts +45 -0
  12. package/dist/constants.js +6 -1
  13. package/dist/constants.js.map +1 -1
  14. package/dist/middleware/cors.d.ts +2 -0
  15. package/dist/middleware/cors.js +2 -1
  16. package/dist/middleware/cors.js.map +1 -1
  17. package/dist/middleware/error.d.ts +4 -0
  18. package/dist/middleware/json.d.ts +2 -0
  19. package/dist/middleware/logger.d.ts +26 -0
  20. package/dist/middleware/logger.js +34 -1
  21. package/dist/middleware/logger.js.map +1 -1
  22. package/dist/middleware/ratelimit.d.ts +2 -0
  23. package/dist/middleware/version.d.ts +3 -0
  24. package/dist/middleware/version.js +2 -2
  25. package/dist/middleware/version.js.map +1 -1
  26. package/dist/modules/v3/algorithms.d.ts +82 -0
  27. package/dist/modules/v3/captcha.d.ts +8 -0
  28. package/dist/modules/v3/chat.d.ts +9 -0
  29. package/dist/modules/v3/chat.js +3 -3
  30. package/dist/modules/v3/chat.js.map +1 -1
  31. package/dist/modules/v3/color.d.ts +6 -0
  32. package/dist/modules/v3/convert.d.ts +10 -0
  33. package/dist/modules/v3/domain.d.ts +6 -0
  34. package/dist/modules/v3/hash.d.ts +8 -0
  35. package/dist/modules/v3/hyperplanning.d.ts +9 -0
  36. package/dist/modules/v3/levenshtein.d.ts +9 -0
  37. package/dist/modules/v3/personal.d.ts +6 -0
  38. package/dist/modules/v3/qrcode.d.ts +8 -0
  39. package/dist/modules/v3/tic_tac_toe.d.ts +9 -0
  40. package/dist/modules/v3/tic_tac_toe.js +3 -3
  41. package/dist/modules/v3/tic_tac_toe.js.map +1 -1
  42. package/dist/modules/v3/time.d.ts +12 -0
  43. package/dist/modules/v3/token.d.ts +9 -0
  44. package/dist/modules/v3/username.d.ts +6 -0
  45. package/dist/modules/v3/utils.d.ts +50 -0
  46. package/dist/modules/v3.d.ts +15 -0
  47. package/dist/modules/v4/address.d.ts +20 -0
  48. package/dist/modules/v4/agent.d.ts +30 -0
  49. package/dist/modules/v4/algorithms.d.ts +90 -0
  50. package/dist/modules/v4/avatar.d.ts +23 -0
  51. package/dist/modules/v4/barcode.d.ts +27 -0
  52. package/dist/modules/v4/captcha.d.ts +22 -0
  53. package/dist/modules/v4/chat.d.ts +21 -0
  54. package/dist/modules/v4/chat.js +3 -3
  55. package/dist/modules/v4/chat.js.map +1 -1
  56. package/dist/modules/v4/color.d.ts +16 -0
  57. package/dist/modules/v4/convert.d.ts +15 -0
  58. package/dist/modules/v4/credit.d.ts +22 -0
  59. package/dist/modules/v4/cron.d.ts +17 -0
  60. package/dist/modules/v4/dice.d.ts +16 -0
  61. package/dist/modules/v4/domain.d.ts +6 -0
  62. package/dist/modules/v4/encode.d.ts +81 -0
  63. package/dist/modules/v4/geo.d.ts +30 -0
  64. package/dist/modules/v4/hash.d.ts +15 -0
  65. package/dist/modules/v4/hyperplanning.d.ts +19 -0
  66. package/dist/modules/v4/ip.d.ts +19 -0
  67. package/dist/modules/v4/levenshtein.d.ts +13 -0
  68. package/dist/modules/v4/palette.d.ts +19 -0
  69. package/dist/modules/v4/password.d.ts +25 -0
  70. package/dist/modules/v4/personal.d.ts +6 -0
  71. package/dist/modules/v4/placeholder.d.ts +30 -0
  72. package/dist/modules/v4/qrcode.d.ts +25 -0
  73. package/dist/modules/v4/regex.d.ts +23 -0
  74. package/dist/modules/v4/statistics.d.ts +20 -0
  75. package/dist/modules/v4/text.d.ts +43 -0
  76. package/dist/modules/v4/tic_tac_toe.d.ts +19 -0
  77. package/dist/modules/v4/tic_tac_toe.js +3 -3
  78. package/dist/modules/v4/tic_tac_toe.js.map +1 -1
  79. package/dist/modules/v4/time.d.ts +15 -0
  80. package/dist/modules/v4/token.d.ts +9 -0
  81. package/dist/modules/v4/username.d.ts +6 -0
  82. package/dist/modules/v4/validate.d.ts +34 -0
  83. package/dist/modules/v4.d.ts +32 -0
  84. package/dist/modules/v5/address.d.ts +5 -0
  85. package/dist/modules/v5/algorithms.d.ts +9 -0
  86. package/dist/modules/v5/asymmetric.d.ts +26 -0
  87. package/dist/modules/v5/barcode.d.ts +27 -0
  88. package/dist/modules/v5/base.d.ts +16 -0
  89. package/dist/modules/v5/base.js +41 -0
  90. package/dist/modules/v5/base.js.map +1 -0
  91. package/dist/modules/v5/case.d.ts +10 -0
  92. package/dist/modules/v5/chart.d.ts +53 -0
  93. package/dist/modules/v5/chat.d.ts +21 -0
  94. package/dist/modules/v5/chat.js +3 -3
  95. package/dist/modules/v5/chat.js.map +1 -1
  96. package/dist/modules/v5/csv.d.ts +29 -0
  97. package/dist/modules/v5/diff.d.ts +20 -0
  98. package/dist/modules/v5/diff.js +81 -0
  99. package/dist/modules/v5/diff.js.map +1 -0
  100. package/dist/modules/v5/evaluate.d.ts +14 -0
  101. package/dist/modules/v5/jwt.d.ts +11 -0
  102. package/dist/modules/v5/matrix.d.ts +77 -0
  103. package/dist/modules/v5/otp.d.ts +30 -0
  104. package/dist/modules/v5/read.d.ts +20 -0
  105. package/dist/modules/v5/read.js +59 -0
  106. package/dist/modules/v5/read.js.map +1 -0
  107. package/dist/modules/v5/semver.d.ts +33 -0
  108. package/dist/modules/v5/semver.js +99 -0
  109. package/dist/modules/v5/semver.js.map +1 -0
  110. package/dist/modules/v5/symmetric.d.ts +15 -0
  111. package/dist/modules/v5/text.d.ts +5 -0
  112. package/dist/modules/v5/tic_tac_toe.d.ts +19 -0
  113. package/dist/modules/v5/tic_tac_toe.js +3 -3
  114. package/dist/modules/v5/tic_tac_toe.js.map +1 -1
  115. package/dist/modules/v5/url.d.ts +18 -0
  116. package/dist/modules/v5/url.js +12 -3
  117. package/dist/modules/v5/url.js.map +1 -1
  118. package/dist/modules/v5/uuid.d.ts +25 -0
  119. package/dist/modules/v5/uuid.js +40 -0
  120. package/dist/modules/v5/uuid.js.map +1 -0
  121. package/dist/modules/v5.d.ts +22 -0
  122. package/dist/modules/v5.js +5 -0
  123. package/dist/modules/v5.js.map +1 -1
  124. package/dist/routes/delete.d.ts +2 -0
  125. package/dist/routes/delete.js +2 -2
  126. package/dist/routes/delete.js.map +1 -1
  127. package/dist/routes/get.d.ts +2 -0
  128. package/dist/routes/get.js +152 -85
  129. package/dist/routes/get.js.map +1 -1
  130. package/dist/routes/index.d.ts +2 -0
  131. package/dist/routes/index.js +25 -5
  132. package/dist/routes/index.js.map +1 -1
  133. package/dist/routes/patch.d.ts +2 -0
  134. package/dist/routes/patch.js +1 -1
  135. package/dist/routes/patch.js.map +1 -1
  136. package/dist/routes/post.d.ts +2 -0
  137. package/dist/routes/post.js +80 -32
  138. package/dist/routes/post.js.map +1 -1
  139. package/dist/storage/index.d.ts +4 -0
  140. package/dist/types/storage.d.ts +49 -0
  141. package/dist/utils/colors.d.ts +44 -0
  142. package/dist/utils/helpers.d.ts +55 -0
  143. package/dist/utils/response.d.ts +9 -0
  144. package/dist/utils/response.js +2 -4
  145. package/dist/utils/response.js.map +1 -1
  146. package/package.json +17 -16
  147. package/robots.txt +74 -0
  148. package/src/favicon.ico +0 -0
@@ -0,0 +1,5 @@
1
+ .github/
2
+ dist/
3
+ node_modules/
4
+ package-lock.json
5
+ package.json
package/README.md CHANGED
@@ -1,50 +1,192 @@
1
- <div align="center">
2
- <a href="https://api.sylvain.sh"><img src="https://api.sylvain.sh/favicon.ico" alt="Logo" width="25%" height="auto"/></a>
1
+ # @20syldev/api
3
2
 
4
- # API Personnelle
3
+ ## About
5
4
 
6
- [![Version](https://custom-icon-badges.demolab.com/badge/Version%20:-v5.6.0-6479ee?logo=api.sylvain.sh&labelColor=23272A)](https://github.com/20syldev/api/releases/latest)
5
+ `@20syldev/api` bundles 42 self-contained utilities: encryption, matrix math, SVG charts, CSV, JWT, TOTP, barcodes, fake data generation, text processing, validation and more. Install it and import — no configuration, no setup step, types included.
7
6
 
8
- </div>
7
+ It works two ways:
9
8
 
10
- ---
9
+ - **As a library** — import any module directly into your code.
10
+ - **As a server** — a single import boots an Express app that exposes every module over HTTP.
11
11
 
12
- ## À propos de l'API
12
+ The HTTP surface is versioned from `v1` to `v5`, and every version stays mounted side by side, so a new release never changes the behaviour of the one you already target. The full endpoint reference lives on [docs.sylvain.sh](https://docs.sylvain.sh).
13
13
 
14
- Voici mon API personnelle, disponible sur le domaine [api.sylvain.sh](https://api.sylvain.sh).
15
- L'API est développée avec **TypeScript** et **Node.js**, et hébergée **24h/7j**. Elle est **simple d'utilisation** et a une **documentation** disponible sur [docs.sylvain.sh](https://docs.sylvain.sh) !
14
+ ## Requirements
16
15
 
17
- > _Une limite de **2000** requêtes **par heure** est fixée. Elle change pour certains endpoints nécessitant plus de ressources. Si vous souhaitez une **augmentation** de cette limite, n'hésitez pas à visiter la [documentation](https://docs.sylvain.sh/pricing)._
16
+ **Node.js >= 22.12.0.** The package ships as ESM, but that does not lock out CommonJS: Node has been able to `require()` an ESM module since 22.12, which is why that is the floor. The library entry works from both module systems.
18
17
 
19
- ## Prérequis
18
+ ```js
19
+ import { evaluate } from '@20syldev/api'; // ESM
20
+ const { evaluate } = require('@20syldev/api'); // CommonJS
21
+ ```
22
+
23
+ The server entry loads its plugins asynchronously, so it must be imported rather than required:
20
24
 
21
- - **Node.js** >= 22.0.0
25
+ ```js
26
+ await import('@20syldev/api/server'); // from CommonJS
27
+ ```
22
28
 
23
- ## Installer le paquet de l'API sur votre machine
29
+ ## Installation
24
30
 
25
31
  ```console
26
- $ sudo apt install nodejs npm
27
32
  $ npm install @20syldev/api
28
- $ npm init
29
33
  ```
30
34
 
31
- > _Attention, vous devez configurer le type sur "**module**" dans votre fichier `package.json`._
35
+ ## Quick start
36
+
37
+ The root import always resolves to the latest version. Use a subpath (`/v1` to `/v5`) to pin a specific one.
38
+
39
+ ```js
40
+ // Latest version, equivalent to '@20syldev/api/v5'
41
+ import { color, evaluate, username } from '@20syldev/api';
42
+
43
+ // Or a specific version
44
+ import { color as colorV4 } from '@20syldev/api/v4';
45
+
46
+ // Evaluate a math expression
47
+ const expr = evaluate('sin(pi / 2) + sqrt(4)', 5);
48
+ console.log(expr.result); // 3
49
+ console.log(expr.expression); // 'sin(pi / 2) + sqrt(4)'
50
+
51
+ // Generate a random color, converted to every common notation
52
+ const c = color();
53
+ console.log(c.hex, c.rgb, c.hsl, c.hsv, c.hwb, c.cmyk);
54
+
55
+ // Generate a random username
56
+ const user = username();
57
+ console.log(user.username);
58
+ ```
59
+
60
+ ## What's inside
61
+
62
+ | Domain | Exports |
63
+ | ------------------ | ------------------------------------------------------------------------------------- |
64
+ | **Crypto** | `asymmetric` `symmetric` `hash` `jwt` `otp` `token` `password` `captcha` |
65
+ | **Math & data** | **`matrix`** **`algorithms`** `evaluate` `statistics` `convert` `csv` |
66
+ | **Text** | **`text`** **`encode`** **`validate`** `caseConvert` `levenshtein` `regex` `parseUrl` |
67
+ | **Graphics** | **`chart`** `barcode` `qrcode` `avatar` `placeholder` `color` `palette` |
68
+ | **Fake data** | `personal` `address` `credit` `username` `dice` `domain` `agent` |
69
+ | **Network & time** | `ip` `geo` `time` `cron` `hyperplanning` |
70
+ | **Stateful** | `chat` `tic_tac_toe` |
71
+
72
+ The six names in **bold** are namespaces — they group related functions, called as `namespace.method()`:
32
73
 
33
- ## Utiliser l'API
74
+ | Namespace | Functions |
75
+ | ---------------- | ------------------------------------------------------------------------------------------------------------------------ |
76
+ | **`algorithms`** | `factorial` `fibonacci` `gcd` `isprime` `primefactors` `primelist` `roman` `anagram` `palindrome` `reverse` `bubblesort` |
77
+ | **`chart`** | `bar` `line` `pie` `donut` |
78
+ | **`encode`** | `base64encode` `base64decode` `urlencode` `urldecode` `binary` `unbinary` `morse` `unmorse` `caesar` `rot13` |
79
+ | **`matrix`** | `add` `subtract` `multiply` `scalar` `transpose` `determinant` `inverse` `identity` |
80
+ | **`text`** | `lorem` `slug` `stats` `number` |
81
+ | **`validate`** | `email` `iban` `luhn` |
34
82
 
35
- ### Option 1 : Démarrer un serveur local
83
+ Everything else is a plain function, called directly.
36
84
 
37
- Pour démarrer un serveur local avec tous les endpoints :
85
+ Two names differ from their HTTP endpoint, because `case` and `url` collide with reserved or global identifiers:
86
+
87
+ | Endpoint | Import |
88
+ | -------- | ------------- |
89
+ | `/case` | `caseConvert` |
90
+ | `/url` | `parseUrl` |
91
+
92
+ > _`personal` generates **fake** profiles (names, emails, jobs, addresses) for seeding and testing — it holds no real data._
93
+
94
+ ## Examples
95
+
96
+ ```js
97
+ import {
98
+ asymmetric,
99
+ caseConvert,
100
+ chart,
101
+ csv,
102
+ evaluate,
103
+ jwt,
104
+ matrix,
105
+ otp,
106
+ parseUrl,
107
+ symmetric,
108
+ validate,
109
+ } from '@20syldev/api/v5';
110
+
111
+ // RSA key generation, encryption and decryption
112
+ const { publicKey, privateKey } = asymmetric('keygen', {});
113
+ const { result: encrypted } = asymmetric('encrypt', { text: 'secret message', publicKey });
114
+ const { result: decrypted } = asymmetric('decrypt', { text: encrypted, privateKey });
115
+ console.log(decrypted); // 'secret message'
116
+
117
+ // AES-256-GCM symmetric encryption, key derived with scrypt
118
+ const { result: blob } = symmetric('encrypt', 'secret message', 'a-strong-key');
119
+ const { result: plain } = symmetric('decrypt', blob, 'a-strong-key');
120
+ console.log(plain); // 'secret message'
121
+
122
+ // TOTP secret, code generation and verification
123
+ const { secret, uri } = otp('secret', { label: 'alice', issuer: 'MyApp' });
124
+ const { code } = otp('generate', { secret });
125
+ const { valid } = otp('verify', { secret, code });
126
+ console.log(valid); // true
127
+
128
+ // Decode a JWT without verifying its signature (inspection only)
129
+ const { header, payload } = jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.qfhpVR4l');
130
+ console.log(header.alg, payload.sub); // 'HS256' '1234567890'
131
+
132
+ // Evaluate a math expression, with a precision
133
+ const { result } = evaluate('log2(8) * (3 + pi)', 4);
134
+ console.log(result); // 18.4248
135
+
136
+ // Matrix product
137
+ const { result: product } = matrix.multiply(
138
+ [
139
+ [1, 2],
140
+ [3, 4],
141
+ ],
142
+ [
143
+ [5, 6],
144
+ [7, 8],
145
+ ],
146
+ );
147
+ console.log(product); // [[19, 22], [43, 50]]
148
+
149
+ // Render an SVG chart in memory
150
+ const { body: svg } = chart.bar(
151
+ { labels: ['Jan', 'Feb', 'Mar'], datasets: [{ label: 'Sales', values: [120, 85, 200] }] },
152
+ { width: 600, height: 300 },
153
+ );
154
+ // body holds a ready-to-serve SVG string
155
+
156
+ // Parse CSV into rows, or format rows back into CSV
157
+ const { rows } = csv('parse', { csv: 'name,age\nAlice,30\nBob,25' });
158
+ console.log(rows); // [{ name: 'Alice', age: '30' }, { name: 'Bob', age: '25' }]
159
+
160
+ // Convert between case styles
161
+ console.log(caseConvert('hello world', 'pascal').result); // 'HelloWorld'
162
+
163
+ // Split a URL into its components
164
+ const parsed = parseUrl('https://example.com/a/b?tag=x&tag=y#top');
165
+ console.log(parsed.host, parsed.port, parsed.params, parsed.fragment);
166
+
167
+ // Validate an email, an IBAN or a card number
168
+ console.log(validate.email('alice@example.com').valid); // true
169
+ ```
170
+
171
+ ## Running the server
172
+
173
+ From the installed package, one import mounts every version:
174
+
175
+ ```js
176
+ import '@20syldev/api/server';
177
+ ```
178
+
179
+ From a clone of the repository:
38
180
 
39
181
  ```console
40
182
  $ npm run build && npm start
41
183
  ```
42
184
 
43
185
  ```console
44
- > @20syldev/api@5.6.0 build
186
+ > @20syldev/api@5.8.0 build
45
187
  > tsc
46
188
 
47
- > @20syldev/api@5.6.0 start
189
+ > @20syldev/api@5.8.0 start
48
190
  > node dist/app.js
49
191
 
50
192
  API is running on
@@ -52,83 +194,65 @@ API is running on
52
194
  - http://localhost:3000
53
195
  ```
54
196
 
55
- Pour le développement avec rechargement automatique :
197
+ For development with automatic reloading:
56
198
 
57
199
  ```console
58
200
  $ npm run dev
59
201
  ```
60
202
 
61
- ### Option 2 : Utiliser les modules directement dans votre code
203
+ Endpoints follow the `/:version/:endpoint` pattern — `GET /v5/color`, `GET /v5/evaluate?expr=2%2B2`, `POST /v5/matrix`. `GET /` lists the available versions, and `GET /:version` lists that version's endpoints with their parameters.
62
204
 
63
- Vous pouvez également importer les modules spécifiques dont vous avez besoin :
205
+ ### Configuration
64
206
 
65
- ```js
66
- // Importer des modules spécifiques depuis la v5
67
- import { evaluate, color, username } from '@20syldev/api/v5';
207
+ Every setting is optional and read from the environment; a `.env` file at the project root is loaded automatically. The server runs with none of them set.
68
208
 
69
- // Évaluer une expression mathématique
70
- const expr = evaluate('sin(pi / 2) + sqrt(4)', 5);
71
- console.log(expr.result); // 3
72
- console.log(expr.expression); // "sin(pi / 2) + sqrt(4)"
209
+ | Variable | Default | Purpose |
210
+ | ------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
211
+ | `PORT` | `3000` | Port the server listens on |
212
+ | `DOCS_URL` | — | Documentation base URL reported by `/`, `/:version` and `/:version/infos` |
213
+ | `REPO_URL` | — | Source repository reported by `/:version/infos` |
214
+ | `INSTANCE_CREATED` | — | Launch date reported by `/:version/infos` |
215
+ | `LOGS_TOKEN` | — | Value required in the `X-Logs-Token` header to read `/logs`; the route answers 404 while unset |
216
+ | `TRUSTED_PROXIES` | one hop | CIDR blocks separated by spaces or commas, or the `loopback` / `linklocal` / `uniquelocal` shorthands, for deployments behind a CDN or platform router |
217
+ | `GLOBAL_LIMIT` | `50000` | Requests per hour accepted across the whole instance |
218
+ | `DEFAULT_LIMIT` | `2000` | Per-client requests per hour |
219
+ | `DEFAULT_BURST` | `50` | Per-client requests per 10-second window |
73
220
 
74
- // Générer une couleur aléatoire
75
- const couleur = color();
76
- console.log(`Couleur HEX: ${couleur.hex}`);
77
- console.log(`Couleur RGB: ${couleur.rgb}`);
221
+ The three metadata variables are omitted from responses when unset, so an instance never advertises somebody else's documentation or repository.
78
222
 
79
- // Générer un nom d'utilisateur aléatoire
80
- const utilisateur = username();
81
- console.log(`Nom d'utilisateur: ${utilisateur.username}`);
82
- ```
223
+ Higher quotas can be granted per client: `ADVANCED_`, `PRO_` and `BUSINESS_` variants of `_LIMIT` and `_BURST` define the tiers, and the matching `*_TOKEN_LIST` variables hold the space-separated bearer tokens that map to them. A client's tier and quota are reported by `GET /auth`.
83
224
 
84
- ## Scripts disponibles
225
+ > _Rate-limit counters live in process memory, so each instance of a multi-instance deployment counts separately._
85
226
 
86
- | Commande | Description |
87
- | ---------------- | ------------------------------------------------------------------ |
88
- | `npm run dev` | Serveur de développement avec rechargement automatique (tsx watch) |
89
- | `npm run build` | Compilation TypeScript vers `dist/` |
90
- | `npm start` | Démarrer le serveur de production (`node dist/app.js`) |
91
- | `npm test` | Lancer les tests unitaires et d'intégration |
92
- | `npm run lint` | Vérification ESLint |
93
- | `npm run format` | Formatage avec Prettier |
94
- | `npm run check` | Vérification TypeScript + ESLint |
227
+ ## Versioning
95
228
 
96
- ## Exemples d'utilisation
229
+ | Version | Adds |
230
+ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
231
+ | `v1` | algorithms, captcha, color, convert, domain, personal, qrcode, username, token |
232
+ | `v2` | chat, hash, tic-tac-toe |
233
+ | `v3` | levenshtein, time, hyperplanning |
234
+ | `v4` | 24 endpoints — address, avatar, barcode, credit, cron, dice, encode, geo, ip, palette, password, placeholder, regex, statistics, text, validate… plus PATCH and DELETE routes |
235
+ | `v5` | case, evaluate, url, asymmetric, chart, csv, jwt, matrix, otp, symmetric |
97
236
 
98
- ```js
99
- import { asymmetric, chart, evaluate, matrix, otp, symmetric } from '@20syldev/api/v5';
237
+ `v4` and `v5` are fully typed. The package root always tracks the latest version.
100
238
 
101
- // Chiffrement RSA asymétrique
102
- const { publicKey, privateKey } = asymmetric('keygen', {});
103
- const { result: encrypted } = asymmetric('encrypt', { text: 'message secret', publicKey });
104
- const { result: decrypted } = asymmetric('decrypt', { text: encrypted, privateKey });
105
- console.log(decrypted); // 'message secret'
239
+ > _`v1`, `v2` and `v3` share the same untyped JavaScript implementation and differ only by the endpoints they expose. They are **deprecated** and will be removed in `6.0.0` — new code should target `v5`._
106
240
 
107
- // Évaluer une expression mathématique
108
- const { result } = evaluate('log2(8) * (3 + pi)', 4);
109
- console.log(result); // 18.4248
241
+ ## Scripts
110
242
 
111
- // Opération matricielle — produit de deux matrices
112
- const { result: product } = matrix.multiply([[1, 2], [3, 4]], [[5, 6], [7, 8]]);
113
- console.log(product); // [[19, 22], [43, 50]]
243
+ | Command | Description |
244
+ | ---------------- | ------------------------------------------------------- |
245
+ | `npm run dev` | Development server with automatic reloading (tsx watch) |
246
+ | `npm run build` | Compile TypeScript to `dist/` |
247
+ | `npm start` | Start the production server (`node dist/app.js`) |
248
+ | `npm test` | Run unit and integration tests |
249
+ | `npm run format` | Format with Prettier and auto-fix with ESLint |
250
+ | `npm run check` | TypeScript and ESLint verification |
114
251
 
115
- // Générer un graphique SVG en mémoire
116
- const { body: svg } = chart.bar(
117
- { labels: ['Jan', 'Fév', 'Mar'], datasets: [{ label: 'Ventes', values: [120, 85, 200] }] },
118
- { width: 600, height: 300 },
119
- );
120
- // body contient une chaîne SVG prête à l'emploi
252
+ ## Hosted instance
121
253
 
122
- // Chiffrement symétrique AES-256-GCM
123
- const { result: blob } = symmetric('encrypt', 'message secret', 'motdepasse');
124
- const { result: plain } = symmetric('decrypt', blob, 'motdepasse');
125
- console.log(plain); // 'message secret'
254
+ A public instance runs at [api.sylvain.sh](https://api.sylvain.sh), with the complete endpoint reference, request examples and usage guides on [docs.sylvain.sh](https://docs.sylvain.sh).
126
255
 
127
- // Générer un secret TOTP et vérifier un code
128
- const { secret } = otp('secret', {});
129
- const { code } = otp('generate', { secret });
130
- const { valid } = otp('verify', { secret, code });
131
- console.log(valid); // true
132
- ```
256
+ ## License
133
257
 
134
- _Visitez la [documentation](https://docs.sylvain.sh) dédiée pour la liste complète des endpoints, des exemples de requêtes et des guides d'utilisation de l'[API](https://api.sylvain.sh)._
258
+ BSD 3-Clause. See [LICENSE](LICENSE).
package/dist/app.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const app: import("express-serve-static-core").Express;
2
+ export default app;
@@ -0,0 +1,21 @@
1
+ export declare function envList(key: string): string[] | null;
2
+ export declare const env: {
3
+ PORT: number;
4
+ TRUSTED_PROXIES: string[] | null;
5
+ DOCS_URL: string;
6
+ REPO_URL: string;
7
+ INSTANCE_CREATED: string;
8
+ LOGS_TOKEN: string;
9
+ DEFAULT_LIMIT: number;
10
+ ADVANCED_LIMIT: number;
11
+ PRO_LIMIT: number;
12
+ BUSINESS_LIMIT: number;
13
+ GLOBAL_LIMIT: number;
14
+ DEFAULT_BURST: number;
15
+ ADVANCED_BURST: number;
16
+ PRO_BURST: number;
17
+ BUSINESS_BURST: number;
18
+ BUSINESS_TOKEN_LIST: string[];
19
+ PRO_TOKEN_LIST: string[];
20
+ ADVANCED_TOKEN_LIST: string[];
21
+ };
@@ -1,9 +1,12 @@
1
1
  import dotenv from 'dotenv';
2
2
  import { DEFAULT_PORT } from '../constants.js';
3
3
  dotenv.config();
4
- function envList(key) {
4
+ export function envList(key) {
5
5
  const v = process.env[key];
6
- return v && v !== 'undefined' ? v.split(' ') : null;
6
+ if (!v || v === 'undefined')
7
+ return null;
8
+ const items = v.split(/[\s,]+/).filter(Boolean);
9
+ return items.length ? items : null;
7
10
  }
8
11
  function envNumber(key, fallback) {
9
12
  const v = parseInt(process.env[key] ?? '', 10);
@@ -11,6 +14,11 @@ function envNumber(key, fallback) {
11
14
  }
12
15
  export const env = {
13
16
  PORT: envNumber('PORT', DEFAULT_PORT),
17
+ TRUSTED_PROXIES: envList('TRUSTED_PROXIES'),
18
+ DOCS_URL: (process.env.DOCS_URL ?? '').replace(/\/+$/, ''),
19
+ REPO_URL: process.env.REPO_URL ?? '',
20
+ INSTANCE_CREATED: process.env.INSTANCE_CREATED ?? '',
21
+ LOGS_TOKEN: process.env.LOGS_TOKEN ?? '',
14
22
  DEFAULT_LIMIT: envNumber('DEFAULT_LIMIT', 2000),
15
23
  ADVANCED_LIMIT: envNumber('ADVANCED_LIMIT', 3500),
16
24
  PRO_LIMIT: envNumber('PRO_LIMIT', 6000),
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,SAAS,OAAO,CAAC,GAAW;IACxB,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,QAAgB;IAC5C,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,GAAG;IACf,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC;IAErC,aAAa,EAAE,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC;IAC/C,cAAc,EAAE,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC;IACjD,SAAS,EAAE,SAAS,CAAC,WAAW,EAAE,IAA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IAAI,EAAE;CAC5D,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Rate limit plans configuration.
3
+ *
4
+ * hourly — max requests per hour (matches pricing page)
5
+ * burst — max requests per 10-second window
6
+ * tokens — list of bearer tokens for this tier
7
+ *
8
+ * To adjust limits, edit the values below or override via .env:
9
+ * DEFAULT_LIMIT, ADVANCED_LIMIT, PRO_LIMIT, BUSINESS_LIMIT
10
+ * DEFAULT_BURST, ADVANCED_BURST, PRO_BURST, BUSINESS_BURST
11
+ */
12
+ export interface Plan {
13
+ hourly: number;
14
+ burst: number;
15
+ tokens: string[];
16
+ }
17
+ export declare const plans: Record<string, Plan>;
18
+ export declare const globalLimit: number;
19
+ /**
20
+ * Returns the plan matching a bearer token, or 'default'.
21
+ * Returns null if the token is provided but invalid.
22
+ */
23
+ export declare function getPlan(token: string): {
24
+ name: string;
25
+ plan: Plan;
26
+ } | null;
@@ -0,0 +1,18 @@
1
+ import * as apiv3 from '../modules/v3.js';
2
+ import * as apiv4 from '../modules/v4.js';
3
+ import * as apiv5 from '../modules/v5.js';
4
+ export interface Endpoint {
5
+ name: string;
6
+ path?: string;
7
+ children?: Record<string, string>;
8
+ }
9
+ export interface VersionConfig {
10
+ endpoints: {
11
+ get: Endpoint[];
12
+ post: Endpoint[];
13
+ patch?: Endpoint[];
14
+ delete?: Endpoint[];
15
+ };
16
+ modules: typeof apiv3 | typeof apiv4 | typeof apiv5;
17
+ }
18
+ export declare const versions: Record<string, VersionConfig>;
@@ -112,17 +112,22 @@ const v4 = {
112
112
  };
113
113
  const v5 = {
114
114
  get: merge(v4.get, [
115
+ { name: 'base', path: '/base?value={value}(&from={from})(&to={to})' },
115
116
  { name: 'case', path: '/case?text={text}(&to={target})' },
116
117
  { name: 'evaluate', path: '/evaluate?expr={expression}(&precision={0-15})' },
118
+ { name: 'semver', path: '/semver?version={version}(&action={action})(&part={part})(&other={other})' },
117
119
  { name: 'url', path: '/url?url={URL}' },
120
+ { name: 'uuid', path: '/uuid(?uuid={uuid})(&count={count})' },
118
121
  ]),
119
122
  post: merge(v4.post, [
120
123
  { name: 'asymmetric', path: '/asymmetric' },
121
124
  { name: 'chart', path: '/chart' },
122
125
  { name: 'csv', path: '/csv' },
126
+ { name: 'diff', path: '/diff' },
123
127
  { name: 'jwt', path: '/jwt' },
124
128
  { name: 'matrix', path: '/matrix' },
125
129
  { name: 'otp', path: '/otp' },
130
+ { name: 'read', path: '/read' },
126
131
  { name: 'symmetric', path: '/symmetric' },
127
132
  ]),
128
133
  patch: [...v4.patch],
@@ -1 +1 @@
1
- {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/config/versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAkB1C;;;;;;;GAOG;AACH,MAAM,KAAK,GAAG,CAAC,IAAgB,EAAE,SAAqB,EAAc,EAAE;IAClE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,KAAK,MAAM,CAAC,IAAI,SAAS;QAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF,MAAM,EAAE,GAAG;IACP,GAAG,EAAE;QACD,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,gEAAgE,EAAE;QAC9F,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,sBAAsB,EAAE;QACjD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE;QACjC,EAAE,IAAI,EAA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E;IACrC,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;IACrC,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;CACxC,CAAC"}
@@ -0,0 +1,45 @@
1
+ export declare const APP_VERSION: string;
2
+ export declare const DEFAULT_PORT = 3000;
3
+ export declare const START_TIME: number;
4
+ export declare const GAME_CLEANUP_TTL = 600000;
5
+ export declare const MAX_LOG_ENTRIES = 1000;
6
+ export declare const RATE_LIMIT_WINDOW = 10000;
7
+ export declare const RATE_LIMIT_MAX = 50;
8
+ export declare const SESSION_TTL = 3600000;
9
+ export declare const STATUS_MESSAGES: Record<number, string>;
10
+ export declare const EARTH_RADIUS_KM = 6371;
11
+ export declare const MAX_ADDRESS_COUNT = 10;
12
+ export declare const MAX_BASE_VALUE_LENGTH = 100;
13
+ export declare const MAX_CHART_DATASETS = 5;
14
+ export declare const MAX_CHART_LABELS = 20;
15
+ export declare const MAX_CSV_LENGTH = 50000;
16
+ export declare const MAX_CSV_ROWS = 1000;
17
+ export declare const MAX_CREDIT_COUNT = 10;
18
+ export declare const MAX_COUNTDOWN_YEARS = 100;
19
+ export declare const MAX_CRON_ITERATIONS: number;
20
+ export declare const MAX_CRON_RESULTS = 20;
21
+ export declare const MAX_DIFF_LENGTH = 10000;
22
+ export declare const MAX_DIFF_PARTS = 2000;
23
+ export declare const MAX_EXPR_DEPTH = 100;
24
+ export declare const MAX_EXPR_LENGTH = 500;
25
+ export declare const MAX_FACTORIAL = 170;
26
+ export declare const MAX_GCD_VALUE = 100000;
27
+ export declare const MAX_JWT_LENGTH = 8192;
28
+ export declare const MAX_LEVENSHTEIN_LENGTH = 1000;
29
+ export declare const MIN_PASSWORD_LENGTH = 8;
30
+ export declare const MAX_PASSWORD_LENGTH = 128;
31
+ export declare const MAX_PASSWORD_COUNT = 20;
32
+ export declare const MAX_MATRIX_SIZE = 20;
33
+ export declare const MAX_PATTERN_LENGTH = 200;
34
+ export declare const MAX_PRIME_LIST = 10000;
35
+ export declare const MAX_QRCODE_LOGO_BYTES: number;
36
+ export declare const MAX_READ_LENGTH = 50000;
37
+ export declare const MAX_REGEX_MATCHES = 100;
38
+ export declare const MAX_RSA_MODULUS = 4096;
39
+ export declare const MAX_SEMVER_LENGTH = 256;
40
+ export declare const MAX_STRING_LENGTH = 1000;
41
+ export declare const MIN_TOKEN_LENGTH = 12;
42
+ export declare const MAX_TOKEN_LENGTH = 4096;
43
+ export declare const MAX_URL_LENGTH = 2048;
44
+ export declare const MAX_UUID_COUNT = 50;
45
+ export declare const ROMAN_VALUES: [number, string][];
package/dist/constants.js CHANGED
@@ -2,7 +2,6 @@ import pkg from '../package.json' with { type: 'json' };
2
2
  // App
3
3
  export const APP_VERSION = pkg.version;
4
4
  export const DEFAULT_PORT = 3000;
5
- export const DOCS_URL = 'https://docs.sylvain.sh';
6
5
  export const START_TIME = Date.now();
7
6
  // Server
8
7
  export const GAME_CLEANUP_TTL = 600_000;
@@ -22,6 +21,7 @@ export const STATUS_MESSAGES = {
22
21
  // Modules
23
22
  export const EARTH_RADIUS_KM = 6371;
24
23
  export const MAX_ADDRESS_COUNT = 10;
24
+ export const MAX_BASE_VALUE_LENGTH = 100;
25
25
  export const MAX_CHART_DATASETS = 5;
26
26
  export const MAX_CHART_LABELS = 20;
27
27
  export const MAX_CSV_LENGTH = 50_000;
@@ -30,6 +30,8 @@ export const MAX_CREDIT_COUNT = 10;
30
30
  export const MAX_COUNTDOWN_YEARS = 100;
31
31
  export const MAX_CRON_ITERATIONS = 365 * 24 * 60;
32
32
  export const MAX_CRON_RESULTS = 20;
33
+ export const MAX_DIFF_LENGTH = 10_000;
34
+ export const MAX_DIFF_PARTS = 2000;
33
35
  export const MAX_EXPR_DEPTH = 100;
34
36
  export const MAX_EXPR_LENGTH = 500;
35
37
  export const MAX_FACTORIAL = 170;
@@ -43,12 +45,15 @@ export const MAX_MATRIX_SIZE = 20;
43
45
  export const MAX_PATTERN_LENGTH = 200;
44
46
  export const MAX_PRIME_LIST = 10_000;
45
47
  export const MAX_QRCODE_LOGO_BYTES = 2 * 1024 * 1024;
48
+ export const MAX_READ_LENGTH = 50_000;
46
49
  export const MAX_REGEX_MATCHES = 100;
47
50
  export const MAX_RSA_MODULUS = 4096;
51
+ export const MAX_SEMVER_LENGTH = 256;
48
52
  export const MAX_STRING_LENGTH = 1000;
49
53
  export const MIN_TOKEN_LENGTH = 12;
50
54
  export const MAX_TOKEN_LENGTH = 4096;
51
55
  export const MAX_URL_LENGTH = 2048;
56
+ export const MAX_UUID_COUNT = 50;
52
57
  export const ROMAN_VALUES = [
53
58
  [1000, 'M'],
54
59
  [900, 'CM'],
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAExD,MAAM;AACN,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAErC,SAAS;AACT,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AACxC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AACpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AACjC,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC,MAAM,CAAC,MAAM,eAAe,GAA2B;IACnD,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,oBAAoB;IACzB,GA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AI,CAAC;IACV,CAAC,EAAE,EAAE,GAAG,CAAC;IACT,CAAC,EAAE,EAAE,IAAI,CAAC;IACV,CAAC,EAAE,EAAE,GAAG,CAAC;IACT,CAAC,CAAC,EAAE,IAAI,CAAC;IACT,CAAC,CAAC,EAAE,GAAG,CAAC;IACR,CAAC,CAAC,EAAE,IAAI,CAAC;IACT,CAAC,CAAC,EAAE,GAAG,CAAC;CACX,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { type Express } from 'express';
2
+ export declare function setupCors(app: Express): void;
@@ -2,10 +2,11 @@ import cors from 'cors';
2
2
  import express from 'express';
3
3
  import { dirname, join } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
+ import { env } from '../config/env.js';
5
6
  const __filename = fileURLToPath(import.meta.url);
6
7
  const __dirname = dirname(__filename);
7
8
  export function setupCors(app) {
8
- app.set('trust proxy', 1);
9
+ app.set('trust proxy', env.TRUSTED_PROXIES ?? 1);
9
10
  app.use(cors({ methods: ['GET', 'POST', 'PATCH', 'DELETE', 'OPTIONS'] }));
10
11
  app.use(express.urlencoded({ extended: true, limit: '10kb' }));
11
12
  app.use(express.json({ limit: '10kb' }));
@@ -1 +1 @@
1
- {"version":3,"file":"cors.js","sourceRoot":"","sources":["../../src/middleware/cors.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAyB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,UAAU,SAAS,CAAC,GAAY;IAClC,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IAC1B,GAAG,CAA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