@20syldev/api 4.1.0 → 4.3.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.
package/docs/changelog.md DELETED
@@ -1,333 +0,0 @@
1
- # Changelog
2
-
3
- ## Exemples curl
4
-
5
- ```bash
6
- # dice
7
- curl -X GET "http://127.0.0.1:3000/v4/dice?roll=2d6%2B3"
8
-
9
- # encode
10
- curl -X GET "http://127.0.0.1:3000/v4/encode?method=base64encode&text=hello"
11
- curl -X GET "http://127.0.0.1:3000/v4/encode?method=morse&text=SOS"
12
- curl -X GET "http://127.0.0.1:3000/v4/encode?method=caesar&text=hello&shift=3"
13
-
14
- # geo
15
- curl -X GET "http://127.0.0.1:3000/v4/geo?lat1=48.8566&lon1=2.3522&lat2=43.2965&lon2=5.3698"
16
-
17
- # palette
18
- curl -X GET "http://127.0.0.1:3000/v4/palette?color=%23ff6600&type=triadic"
19
-
20
- # statistics
21
- curl -X GET "http://127.0.0.1:3000/v4/statistics?values=1,2,3,4,5"
22
-
23
- # text - stats
24
- curl -X GET "http://127.0.0.1:3000/v4/text?method=stats&value=Hello+world"
25
-
26
- # text - slug
27
- curl -X GET "http://127.0.0.1:3000/v4/text?method=slug&value=Héllo+Wörld%21"
28
-
29
- # text - lorem
30
- curl -X GET "http://127.0.0.1:3000/v4/text?method=lorem&type=sentences&count=3"
31
-
32
- # text - number
33
- curl -X GET "http://127.0.0.1:3000/v4/text?method=number&value=42&lang=fr"
34
-
35
- # validate - luhn
36
- curl -X GET "http://127.0.0.1:3000/v4/validate?type=luhn&value=4532015112830366"
37
-
38
- # validate - iban
39
- curl -X GET "http://127.0.0.1:3000/v4/validate?type=iban&value=FR7630006000011234567890189"
40
-
41
- # validate - email
42
- curl -X GET "http://127.0.0.1:3000/v4/validate?type=email&value=user%40example.com"
43
-
44
- # algorithms - roman
45
- curl -X GET "http://127.0.0.1:3000/v4/algorithms?method=roman&value=42"
46
- curl -X GET "http://127.0.0.1:3000/v4/algorithms?method=roman&value=XLII"
47
-
48
- # REST v4.2 - jouer un coup (PATCH)
49
- curl -X PATCH "http://127.0.0.1:3000/v4/tic-tac-toe/{gameId}" \
50
- -H "Content-Type: application/json" \
51
- -d '{"username":"alice","move":"A1","session":"abc123"}'
52
-
53
- # REST v4.2 - forfait (DELETE tic-tac-toe)
54
- curl -X DELETE "http://127.0.0.1:3000/v4/tic-tac-toe/{gameId}" \
55
- -H "Content-Type: application/json" \
56
- -d '{"username":"alice","session":"abc123"}'
57
-
58
- # REST v4.2 - vider un chat (DELETE chat)
59
- curl -X DELETE "http://127.0.0.1:3000/v4/chat/{token}" \
60
- -H "Content-Type: application/json" \
61
- -d '{"username":"alice","session":"abc123"}'
62
- ```
63
-
64
-
65
-
66
- ## v4.2.0
67
-
68
- ### REST endpoints pour tic-tac-toe et chat
69
-
70
- Les endpoints existants ont été étendus avec des méthodes HTTP REST. Uniquement disponible en `v4+`.
71
-
72
- #### PATCH `/v4/tic-tac-toe/:game`
73
-
74
- Jouer un coup dans une partie.
75
-
76
- **Body (JSON) :**
77
- | Param | Type | Description |
78
- |-------|------|-------------|
79
- | `username` | string | Nom du joueur |
80
- | `move` | string | Case jouée (ex: `A1`) |
81
- | `session` | string | ID de session |
82
-
83
- ---
84
-
85
- #### DELETE `/v4/tic-tac-toe/:game`
86
-
87
- Abandonner une partie (forfeit).
88
-
89
- **Body (JSON) :**
90
- | Param | Type | Description |
91
- |-------|------|-------------|
92
- | `username` | string | Nom du joueur |
93
- | `session` | string | ID de session |
94
-
95
- ---
96
-
97
- #### DELETE `/v4/chat/:token`
98
-
99
- Effacer tous les messages d'un chat privé (clear).
100
-
101
- **Body (JSON) :**
102
- | Param | Type | Description |
103
- |-------|------|-------------|
104
- | `username` | string | Nom de l'utilisateur |
105
- | `session` | string | ID de session |
106
-
107
- ---
108
-
109
- ### Autres changements v4.2.0
110
-
111
- - CORS : ajout de `PATCH`, `DELETE`, `OPTIONS` dans les headers autorisés
112
- - Nouveau helper `supportsRest()` dans `src/utils/version.ts`
113
-
114
- ---
115
-
116
- ## v4.1.0
117
-
118
- ### Nouveaux endpoints
119
-
120
- #### GET `/v4/dice`
121
-
122
- Lance des dés en notation RPG.
123
-
124
- **Query params :**
125
- | Param | Requis | Description | Exemple |
126
- |-------|--------|-------------|---------|
127
- | `roll` | oui | Notation NdX ou NdX+M | `2d6+3` |
128
-
129
- **Note :** le `+` dans l'URL peut être encodé en espace (`2d6 3`) — les deux sont acceptés.
130
-
131
- **Réponse :**
132
- ```json
133
- {
134
- "roll": "2d6+3",
135
- "count": 2,
136
- "sides": 6,
137
- "modifier": 3,
138
- "results": [4, 2],
139
- "total": 9
140
- }
141
- ```
142
-
143
- Limites : 1–100 dés, 2–1000 faces.
144
-
145
- ---
146
-
147
- #### GET `/v4/encode`
148
-
149
- Encode ou décode du texte dans différents formats.
150
-
151
- **Query params :**
152
- | Param | Requis | Description |
153
- |-------|--------|-------------|
154
- | `method` | oui | Voir liste ci-dessous |
155
- | `value` | oui | Texte à traiter |
156
- | `shift` | non | Décalage pour Caesar (défaut : 13) |
157
-
158
- **Méthodes disponibles :**
159
- | `method` | Description |
160
- |----------|-------------|
161
- | `base64encode` | Encode en Base64 |
162
- | `base64decode` | Décode du Base64 |
163
- | `urlencode` | Encode pour URL |
164
- | `urldecode` | Décode une URL |
165
- | `morse` | Texte → Morse |
166
- | `unmorse` | Morse → Texte |
167
- | `rot13` | ROT-13 |
168
- | `caesar` | Chiffre de César (nécessite `shift`) |
169
- | `binary` | Texte → binaire 8 bits |
170
- | `unbinary` | Binaire → texte |
171
-
172
- ---
173
-
174
- #### GET `/v4/geo`
175
-
176
- Calcule la distance et le cap entre deux coordonnées GPS (Haversine).
177
-
178
- **Query params :**
179
- | Param | Requis | Description |
180
- |-------|--------|-------------|
181
- | `lat1` | oui | Latitude point A (-90/+90) |
182
- | `lon1` | oui | Longitude point A (-180/+180) |
183
- | `lat2` | oui | Latitude point B |
184
- | `lon2` | oui | Longitude point B |
185
-
186
- **Réponse :**
187
- ```json
188
- {
189
- "distance": { "km": 1214.652, "miles": 754.801, "nauticalMiles": 655.879 },
190
- "bearing": { "degrees": 157.34, "cardinal": "SSE" },
191
- "from": { "lat": 48.8566, "lon": 2.3522 },
192
- "to": { "lat": 43.2965, "lon": 5.3698 }
193
- }
194
- ```
195
-
196
- ---
197
-
198
- #### GET `/v4/palette`
199
-
200
- Génère une palette de couleurs harmonieuse à partir d'une couleur HEX.
201
-
202
- **Query params :**
203
- | Param | Requis | Description |
204
- |-------|--------|-------------|
205
- | `color` | oui | Couleur base en HEX (`#RRGGBB`) |
206
- | `type` | oui | Type de palette |
207
-
208
- **Types disponibles :**
209
- | `type` | Couleurs générées |
210
- |--------|------------------|
211
- | `complementary` | 2 couleurs (opposées) |
212
- | `triadic` | 3 couleurs (120°) |
213
- | `analogous` | 5 couleurs (-60° à +60°) |
214
- | `tetradic` | 4 couleurs (90°) |
215
- | `split-complementary` | 3 couleurs |
216
-
217
- Chaque couleur retournée a `hex`, `rgb`, `hsl`.
218
-
219
- ---
220
-
221
- #### GET `/v4/statistics`
222
-
223
- Calcule des statistiques descriptives sur une liste de nombres.
224
-
225
- **Query params :**
226
- | Param | Requis | Description |
227
- |-------|--------|-------------|
228
- | `values` | oui | Nombres séparés par des virgules |
229
-
230
- **Réponse :**
231
- ```json
232
- {
233
- "count": 5,
234
- "sum": 15,
235
- "min": 1,
236
- "max": 5,
237
- "range": 4,
238
- "mean": 3,
239
- "median": 3,
240
- "mode": [],
241
- "variance": 2,
242
- "stddev": 1.414214
243
- }
244
- ```
245
-
246
- ---
247
-
248
- #### GET `/v4/text`
249
-
250
- Manipulation et génération de texte.
251
-
252
- **Query params :**
253
- | Param | Requis | Description |
254
- |-------|--------|-------------|
255
- | `action` | oui | Voir liste ci-dessous |
256
- | `value` | non | Texte source (selon action) |
257
- | `type` | non | `words`, `sentences`, `paragraphs` (pour `lorem`) |
258
- | `count` | non | Nombre d'éléments (pour `lorem`, défaut 5) |
259
- | `lang` | non | `fr` ou `en` (pour `number`) |
260
-
261
- **Actions disponibles :**
262
- | `action` | Description | Params requis |
263
- |----------|-------------|---------------|
264
- | `stats` | Statistiques du texte | `value` |
265
- | `slug` | Convertit en slug URL | `value` |
266
- | `lorem` | Génère du Lorem Ipsum | `type`, `count` |
267
- | `number` | Nombre en lettres | `value`, `lang` |
268
-
269
- **Réponse `stats` :**
270
- ```json
271
- {
272
- "characters": 42,
273
- "charactersNoSpaces": 35,
274
- "words": 8,
275
- "sentences": 2,
276
- "paragraphs": 1,
277
- "readingTime": "3s",
278
- "mostFrequentChar": "e"
279
- }
280
- ```
281
-
282
- ---
283
-
284
- #### GET `/v4/validate`
285
-
286
- Valide différents formats de données.
287
-
288
- **Query params :**
289
- | Param | Requis | Description |
290
- |-------|--------|-------------|
291
- | `type` | oui | `luhn`, `iban`, `email` |
292
- | `value` | oui | Valeur à valider |
293
-
294
- **Réponse `luhn` (numéro de carte) :**
295
- ```json
296
- { "valid": true, "value": "4532015112830366" }
297
- ```
298
-
299
- **Réponse `iban` :**
300
- ```json
301
- { "valid": true, "value": "FR7630006000011234567890189", "country": "FR" }
302
- ```
303
-
304
- **Réponse `email` :**
305
- ```json
306
- { "valid": true, "value": "user@example.com" }
307
- ```
308
-
309
- ---
310
-
311
- ### Ajout à un endpoint existant
312
-
313
- #### GET `/v4/algorithms` — conversion de chiffres romains
314
-
315
- Nouvelle action `roman` sur l'endpoint algorithms.
316
-
317
- **Query params :**
318
- | Param | Requis | Description |
319
- |-------|--------|-------------|
320
- | `method` | oui | `roman` |
321
- | `value` | oui | Nombre entier (1–3999) ou chiffre romain |
322
-
323
- Bidirectionnel : `42` → `XLII`, `XLII` → `42`.
324
-
325
- ---
326
-
327
- ### Infrastructure v4.1.0
328
-
329
- - **`src/app.ts`** : `export default app` + guard `NODE_ENV !== 'test'` pour les tests d'intégration
330
- - **`src/config/versions.ts`** : helper `merge()` pour dédoublonner les endpoints par `name`
331
- - **`tsconfig.test.json`** : étend le tsconfig principal, inclut `src/` et `tests/`
332
- - **`tests/tsconfig.json`** : pointe vers `tsconfig.test.json` pour la résolution IDE
333
- - **`package.json`** : script `npm test` avec `--test-force-exit` (requis car `setTimeout` dans chat/tic-tac-toe)
@@ -1,5 +0,0 @@
1
- import type { Request } from 'express';
2
-
3
- const REST_VERSIONS = new Set(['v4']);
4
-
5
- export const supportsRest = (req: Request): boolean => REST_VERSIONS.has(req.version);