@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
package/README.md CHANGED
@@ -1,41 +1,50 @@
1
1
  <div align="center">
2
2
  <a href="https://api.sylvain.sh"><img src="https://api.sylvain.sh/favicon.ico" alt="Logo" width="25%" height="auto"/></a>
3
3
 
4
- # API Personnelle
5
- [![Version](https://custom-icon-badges.demolab.com/badge/Version%20:-v4.8.0-6479ee?logo=api.sylvain.sh&labelColor=23272A)](https://github.com/20syldev/api/releases/latest)
4
+ # API Personnelle
5
+
6
+ [![Version](https://custom-icon-badges.demolab.com/badge/Version%20:-v4.9.0-6479ee?logo=api.sylvain.sh&labelColor=23272A)](https://github.com/20syldev/api/releases/latest)
7
+
6
8
  </div>
7
9
 
8
10
  ---
9
11
 
10
12
  ## À propos de l'API
13
+
11
14
  Voici mon API personnelle, disponible sur le domaine [api.sylvain.sh](https://api.sylvain.sh).
12
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) !
13
- > *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
+
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)._
14
18
 
15
19
  ## Prérequis
20
+
16
21
  - **Node.js** >= 22.0.0
17
22
 
18
23
  ## Installer le paquet de l'API sur votre machine
24
+
19
25
  ```console
20
26
  $ sudo apt install nodejs npm
21
27
  $ npm install @20syldev/api
22
28
  $ npm init
23
29
  ```
24
- > *Attention, vous devez configurer le type sur "**module**" dans votre fichier `package.json`.*
30
+
31
+ > _Attention, vous devez configurer le type sur "**module**" dans votre fichier `package.json`._
25
32
 
26
33
  ## Utiliser l'API
27
34
 
28
35
  ### Option 1 : Démarrer un serveur local
29
36
 
30
37
  Pour démarrer un serveur local avec tous les endpoints :
38
+
31
39
  ```console
32
40
  $ npm run build && npm start
33
41
  ```
42
+
34
43
  ```console
35
- > @20syldev/api@4.8.0 build
44
+ > @20syldev/api@4.9.0 build
36
45
  > tsc
37
46
 
38
- > @20syldev/api@4.8.0 start
47
+ > @20syldev/api@4.9.0 start
39
48
  > node dist/app.js
40
49
 
41
50
  API is running on
@@ -44,6 +53,7 @@ API is running on
44
53
  ```
45
54
 
46
55
  Pour le développement avec rechargement automatique :
56
+
47
57
  ```console
48
58
  $ npm run dev
49
59
  ```
@@ -73,49 +83,76 @@ console.log(`Jeton: ${jeton}`);
73
83
 
74
84
  ## Scripts disponibles
75
85
 
76
- | Commande | Description |
77
- |----------|-------------|
78
- | `npm run dev` | Serveur de développement avec rechargement automatique (tsx watch) |
79
- | `npm run build` | Compilation TypeScript vers `dist/` |
80
- | `npm start` | Démarrer le serveur de production (`node dist/app.js`) |
81
- | `npm run lint` | Vérification ESLint |
82
- | `npm run format` | Formatage avec Prettier |
83
- | `npm run check` | Vérification TypeScript + ESLint |
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 |
95
+
96
+ ## Endpoints disponibles (v4)
97
+
98
+ | Endpoint | Méthode | Description |
99
+ | ------------------- | ---------- | ------------------------------------------------------- |
100
+ | `/v4/address` | GET | Génération d'adresses postales aléatoires |
101
+ | `/v4/agent` | GET | Analyse de User-Agent |
102
+ | `/v4/algorithms` | GET | Fonctions algorithmiques (tri, fibonacci, factorielle…) |
103
+ | `/v4/avatar` | GET | Génération d'avatars identicon/pixel |
104
+ | `/v4/barcode` | GET | Génération de codes-barres (Code128, EAN-13/8, Code39) |
105
+ | `/v4/captcha` | GET | Génération d'images captcha |
106
+ | `/v4/chat` | GET / POST | Système de chat temporaire |
107
+ | `/v4/color` | GET | Génération de couleurs aléatoires |
108
+ | `/v4/convert` | GET | Conversions d'unités |
109
+ | `/v4/credit` | GET | Génération de cartes bancaires fictives (Luhn valide) |
110
+ | `/v4/cron` | GET | Analyse d'expressions cron |
111
+ | `/v4/dice` | GET | Lanceur de dés RPG |
112
+ | `/v4/domain` | GET | Informations de domaine aléatoires |
113
+ | `/v4/encode` | GET | Encodage / décodage |
114
+ | `/v4/geo` | GET | Calcul de distance géographique |
115
+ | `/v4/hash` | POST | Hachage de texte |
116
+ | `/v4/headers` | GET | Informations des en-têtes HTTP |
117
+ | `/v4/hyperplanning` | POST | Analyse de calendriers HyperPlanning |
118
+ | `/v4/infos` | GET | Informations sur l'API |
119
+ | `/v4/ip` | GET | Analyse d'adresses IP |
120
+ | `/v4/levenshtein` | GET | Distance entre chaînes |
121
+ | `/v4/palette` | GET | Génération de palettes de couleurs |
122
+ | `/v4/password` | GET | Génération de mots de passe sécurisés |
123
+ | `/v4/personal` | GET | Profil personnel aléatoire |
124
+ | `/v4/placeholder` | GET | Génération d'images placeholder |
125
+ | `/v4/qrcode` | GET | Génération de QR codes |
126
+ | `/v4/regex` | GET | Test d'expressions régulières |
127
+ | `/v4/statistics` | GET | Statistiques descriptives |
128
+ | `/v4/text` | GET | Utilitaires texte |
129
+ | `/v4/tic-tac-toe` | GET / POST | Jeu de morpion |
130
+ | `/v4/time` | GET | Informations temporelles |
131
+ | `/v4/token` | POST | Génération de jetons sécurisés |
132
+ | `/v4/username` | GET | Génération de noms d'utilisateur |
133
+ | `/v4/validate` | GET | Validation (Luhn, IBAN, email) |
134
+
135
+ ## Exemples d'utilisation
84
136
 
85
- ## Modules disponibles
137
+ ```js
138
+ import { avatar, barcode, credit, cron } from '@20syldev/api/v4';
86
139
 
87
- L'API v4 expose plusieurs modules que vous pouvez importer :
140
+ // Générer une carte bancaire fictive Luhn-valide
141
+ const { cards } = credit('visa', 1, 'full');
142
+ console.log(cards[0].formatted); // "4532 9876 5432 1098"
143
+ console.log(cards[0].cvv); // "847"
88
144
 
89
- ```js
90
- import {
91
- address, // Génération d'adresses postales aléatoires
92
- agent, // Analyse de User-Agent (navigateur, OS, appareil)
93
- algorithms, // Fonctions algorithmiques diverses
94
- captcha, // Génération d'images captcha
95
- chat, // Système de chat temporaire
96
- color, // Génération de couleurs aléatoires
97
- convert, // Conversions d'unités
98
- dice, // Lanceur de dés RPG
99
- domain, // Informations de domaine aléatoires
100
- encode, // Encodage / décodage (base64, morse, rot13, caesar, binaire)
101
- geo, // Informations de géolocalisation
102
- hash, // Hachage de texte
103
- hyperplanning, // Analyse de calendriers
104
- ip, // Analyse d'adresses IPv4/IPv6
105
- levenshtein, // Distance entre chaînes
106
- palette, // Génération de palettes de couleurs
107
- password, // Génération de mots de passe sécurisés
108
- personal, // Informations personnelles aléatoires
109
- placeholder, // Génération d'images placeholder
110
- qrcode, // Génération de QR codes
111
- statistics, // Statistiques descriptives
112
- text, // Utilitaires texte (slug, stats, lorem, nombre en lettres)
113
- tic_tac_toe, // Jeu de morpion
114
- time, // Informations temporelles
115
- token, // Génération de jetons sécurisés
116
- username, // Génération de noms d'utilisateur
117
- validate // Validation (Luhn, IBAN, email)
118
- } from '@20syldev/api/v4';
145
+ // Générer un avatar identicon SVG déterministe
146
+ const { body } = avatar({ seed: 'john', format: 'svg', size: 200 });
147
+ // body contient une chaîne SVG
148
+
149
+ // Générer un code-barres Code128
150
+ const { body: svg } = barcode({ data: 'Hello World' });
151
+ // body contient une chaîne SVG
152
+
153
+ // Analyser une expression cron
154
+ const { next } = cron('0 9 * * 1-5', 3);
155
+ console.log(next); // ["2026-05-12T09:00:00.000Z", ...]
119
156
  ```
120
157
 
121
- *Visitez la [documentation](https://docs.sylvain.sh) dédiée, vous y retrouverez des exemples de requêtes et des codes simples pour tester l'[API](https://api.sylvain.sh) !*
158
+ _Visitez la [documentation](https://docs.sylvain.sh) dédiée, vous y retrouverez des exemples de requêtes et des codes simples pour tester l'[API](https://api.sylvain.sh) !_
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
- "version": "4.8.0",
2
+ "version": "4.9.0",
3
3
  "name": "@20syldev/api",
4
4
  "description": "Node.js API with multiple features. Check the documentation at https://docs.sylvain.sh",
5
5
  "main": "dist/app.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
+ "prepare": "tsc",
8
9
  "dev": "tsx watch src/app.ts",
9
10
  "start": "node dist/app.js",
10
11
  "build": "tsc",
@@ -1 +0,0 @@
1
- github: [20syldev]
package/.prettierrc DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "tabWidth": 4,
3
- "singleQuote": true,
4
- "semi": true,
5
- "printWidth": 120,
6
- "trailingComma": "all"
7
- }
package/eslint.config.js DELETED
@@ -1,24 +0,0 @@
1
- import eslint from '@eslint/js';
2
- import simpleImportSort from 'eslint-plugin-simple-import-sort';
3
- import tseslint from 'typescript-eslint';
4
- import eslintConfigPrettier from 'eslint-config-prettier';
5
-
6
- export default tseslint.config(
7
- eslint.configs.recommended,
8
- ...tseslint.configs.strict,
9
- eslintConfigPrettier,
10
- {
11
- plugins: { 'simple-import-sort': simpleImportSort },
12
- rules: {
13
- 'simple-import-sort/imports': 'error',
14
- 'simple-import-sort/exports': 'error',
15
- '@typescript-eslint/no-explicit-any': 'warn',
16
- '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
17
- '@typescript-eslint/no-non-null-assertion': 'off',
18
- '@typescript-eslint/no-dynamic-delete': 'off',
19
- },
20
- },
21
- {
22
- ignores: ['dist/', 'node_modules/', 'src/modules/v3/'],
23
- },
24
- );
package/robots.txt DELETED
@@ -1,74 +0,0 @@
1
- User-agent: 360Spider
2
- User-agent: 360Spider-Image
3
- User-agent: 360Spider-Video
4
- User-agent: AdsBot-Google
5
- User-agent: AdsBot-Google-Mobile
6
- User-agent: AdsBot-Google-Mobile-Apps
7
- User-agent: adidxbot
8
- User-agent: Applebot
9
- User-agent: AppleNewsBot
10
- User-agent: Baiduspider
11
- User-agent: Baiduspider-image
12
- User-agent: Baiduspider-news
13
- User-agent: Baiduspider-video
14
- User-agent: bingbot
15
- User-agent: BingPreview
16
- User-agent: BublupBot
17
- User-agent: CCBot
18
- User-agent: Cliqzbot
19
- User-agent: coccoc
20
- User-agent: coccocbot-image
21
- User-agent: coccocbot-web
22
- User-agent: Daumoa
23
- User-agent: Dazoobot
24
- User-agent: DeuSu
25
- User-agent: DuckDuckBot
26
- User-agent: DuckDuckGo-Favicons-Bot
27
- User-agent: EuripBot
28
- User-agent: Exploratodo
29
- User-agent: Facebot
30
- User-agent: Feedly
31
- User-agent: Findxbot
32
- User-agent: Googlebot
33
- User-agent: Googlebot-Image
34
- User-agent: Googlebot-Mobile
35
- User-agent: Googlebot-News
36
- User-agent: Googlebot-Video
37
- User-agent: HaoSouSpider
38
- User-agent: ichiro
39
- User-agent: istellabot
40
- User-agent: JikeSpider
41
- User-agent: Lycos
42
- User-agent: Mail.Ru
43
- User-agent: Mediapartners-Google
44
- User-agent: MojeekBot
45
- User-agent: msnbot
46
- User-agent: msnbot-media
47
- User-agent: OrangeBot
48
- User-agent: Pinterest
49
- User-agent: Plukkie
50
- User-agent: Qwantify
51
- User-agent: Rambler
52
- User-agent: SeznamBot
53
- User-agent: Sosospider
54
- User-agent: Slurp
55
- User-agent: Sogou blog
56
- User-agent: Sogou inst spider
57
- User-agent: Sogou News Spider
58
- User-agent: Sogou Orion spider
59
- User-agent: Sogou spider2
60
- User-agent: Sogou web spider
61
- User-agent: SputnikBot
62
- User-agent: Teoma
63
- User-agent: Twitterbot
64
- User-agent: wotbox
65
- User-agent: yacybot
66
- User-agent: Yandex
67
- User-agent: YandexMobileBot
68
- User-agent: Yeti
69
- User-agent: YioopBot
70
- User-agent: yoozBot
71
- User-agent: YoudaoBot
72
- Disallow:
73
- User-agent: *
74
- Disallow: /
package/src/app.ts DELETED
@@ -1,53 +0,0 @@
1
- import express from 'express';
2
-
3
- import { env } from './config/env.js';
4
- import { setupCors } from './middleware/cors.js';
5
- import { errorHandler } from './middleware/error.js';
6
- import { jsonResponseMiddleware } from './middleware/json.js';
7
- import { loggerMiddleware } from './middleware/logger.js';
8
- import { rateLimitMiddleware } from './middleware/ratelimit.js';
9
- import { endpointCheckMiddleware, versionCheckMiddleware } from './middleware/version.js';
10
- import deleteRoutes from './routes/delete.js';
11
- import getRoutes from './routes/get.js';
12
- import indexRoutes from './routes/index.js';
13
- import patchRoutes from './routes/patch.js';
14
- import postRoutes from './routes/post.js';
15
-
16
- const app = express();
17
-
18
- // Setup CORS, body parsing, static files
19
- setupCors(app);
20
-
21
- // Custom JSON response
22
- app.use(jsonResponseMiddleware);
23
-
24
- // Rate limiting
25
- app.use(rateLimitMiddleware);
26
-
27
- // Request logging
28
- app.use(loggerMiddleware);
29
-
30
- // Error handling
31
- app.use(errorHandler);
32
-
33
- // Root routes (before version check)
34
- app.use(indexRoutes);
35
-
36
- // Version & endpoint validation
37
- app.use('/:version', versionCheckMiddleware);
38
- app.use('/:version/:endpoint', endpointCheckMiddleware);
39
-
40
- // Versioned routes
41
- app.use(getRoutes);
42
- app.use(postRoutes);
43
- app.use(patchRoutes);
44
- app.use(deleteRoutes);
45
-
46
- // Start server
47
- if (process.env.NODE_ENV !== 'test') {
48
- app.listen(env.PORT, () =>
49
- console.log(`API is running on\n - http://127.0.0.1:${env.PORT}\n - http://localhost:${env.PORT}`),
50
- );
51
- }
52
-
53
- export default app;
package/src/config/env.ts DELETED
@@ -1,87 +0,0 @@
1
- import dotenv from 'dotenv';
2
-
3
- import { DEFAULT_PORT } from '../constants.js';
4
-
5
- dotenv.config();
6
-
7
- function envList(key: string): string[] | null {
8
- const v = process.env[key];
9
- return v && v !== 'undefined' ? v.split(' ') : null;
10
- }
11
-
12
- function envNumber(key: string, fallback: number): number {
13
- const v = parseInt(process.env[key] ?? '', 10);
14
- return isNaN(v) ? fallback : v;
15
- }
16
-
17
- export const env = {
18
- PORT: envNumber('PORT', DEFAULT_PORT),
19
- GITHUB_TOKEN: process.env.GITHUB_TOKEN ?? '',
20
-
21
- DEFAULT_LIMIT: envNumber('DEFAULT_LIMIT', 2000),
22
- ADVANCED_LIMIT: envNumber('ADVANCED_LIMIT', 3500),
23
- PRO_LIMIT: envNumber('PRO_LIMIT', 6000),
24
- BUSINESS_LIMIT: envNumber('BUSINESS_LIMIT', 10000),
25
- GLOBAL_LIMIT: envNumber('GLOBAL_LIMIT', 50000),
26
-
27
- DEFAULT_BURST: envNumber('DEFAULT_BURST', 50),
28
- ADVANCED_BURST: envNumber('ADVANCED_BURST', 80),
29
- PRO_BURST: envNumber('PRO_BURST', 120),
30
- BUSINESS_BURST: envNumber('BUSINESS_BURST', 200),
31
-
32
- BUSINESS_TOKEN_LIST: envList('BUSINESS_TOKEN_LIST') ?? [],
33
- PRO_TOKEN_LIST: envList('PRO_TOKEN_LIST') ?? [],
34
- ADVANCED_TOKEN_LIST: envList('ADVANCED_TOKEN_LIST') ?? [],
35
-
36
- // Website endpoint env vars
37
- G_2048: process.env.G_2048,
38
- API: process.env.API,
39
- CDN: process.env.CDN,
40
- COOP_API: process.env.COOP_API,
41
- COOP_STATUS: process.env.COOP_STATUS,
42
- CHAT: process.env.CHAT,
43
- DIGIT: process.env.DIGIT,
44
- DOC_COOPBOT: process.env.DOC_COOPBOT,
45
- DOCS: process.env.DOCS,
46
- DONUT: process.env.DONUT,
47
- DRAWIO_PLUGIN: process.env.DRAWIO_PLUGIN,
48
- FLOWERS: process.env.FLOWERS,
49
- GEMSYNC: process.env.GEMSYNC,
50
- GFT: process.env.GFT,
51
- GITSITE: process.env.GITSITE,
52
- LEBONCHAR: process.env.LEBONCHAR,
53
- LOGGER: process.env.LOGGER,
54
- LOGS: process.env.LOGS,
55
- LOGVAULT: process.env.LOGVAULT,
56
- LYAH: process.env.LYAH,
57
- MINIFY: process.env.MINIFY,
58
- MN: process.env.MN,
59
- MONITORING: process.env.MONITORING,
60
- MORPION: process.env.MORPION,
61
- NITROGEN: process.env.NITROGEN,
62
- OLD_DATABASE: process.env.OLD_DATABASE,
63
- PASSWORD: process.env.PASSWORD,
64
- PHP: process.env.PHP,
65
- PLANNING: process.env.PLANNING,
66
- PING: process.env.PING,
67
- PORTFOLIO: process.env.PORTFOLIO,
68
- PYTHON_API: process.env.PYTHON_API,
69
- README: process.env.README,
70
- TIMESTAMP: process.env.TIMESTAMP,
71
- TERMINAL: process.env.TERMINAL,
72
- VALENTINE: process.env.VALENTINE,
73
- WRKIT: process.env.WRKIT,
74
- ZPKI: process.env.ZPKI,
75
-
76
- PATCH: envList('PATCH'),
77
- RECENT: envList('RECENT'),
78
- NEW: envList('NEW'),
79
- DOMAINS: envList('DOMAINS'),
80
-
81
- STATS1: process.env.STATS1,
82
- STATS2: process.env.STATS2,
83
- STATS3: process.env.STATS3,
84
- STATS4: process.env.STATS4,
85
- TAG: process.env.TAG,
86
- ACTIVE: process.env.ACTIVE === 'true',
87
- };
@@ -1,61 +0,0 @@
1
- import { env } from './env.js';
2
-
3
- /**
4
- * Rate limit plans configuration.
5
- *
6
- * hourly — max requests per hour (matches pricing page)
7
- * burst — max requests per 10-second window
8
- * tokens — list of bearer tokens for this tier
9
- *
10
- * To adjust limits, edit the values below or override via .env:
11
- * DEFAULT_LIMIT, ADVANCED_LIMIT, PRO_LIMIT, BUSINESS_LIMIT
12
- * DEFAULT_BURST, ADVANCED_BURST, PRO_BURST, BUSINESS_BURST
13
- */
14
-
15
- export interface Plan {
16
- hourly: number;
17
- burst: number;
18
- tokens: string[];
19
- }
20
-
21
- export const plans: Record<string, Plan> = {
22
- business: {
23
- hourly: env.BUSINESS_LIMIT,
24
- burst: env.BUSINESS_BURST,
25
- tokens: env.BUSINESS_TOKEN_LIST,
26
- },
27
- pro: {
28
- hourly: env.PRO_LIMIT,
29
- burst: env.PRO_BURST,
30
- tokens: env.PRO_TOKEN_LIST,
31
- },
32
- advanced: {
33
- hourly: env.ADVANCED_LIMIT,
34
- burst: env.ADVANCED_BURST,
35
- tokens: env.ADVANCED_TOKEN_LIST,
36
- },
37
- default: {
38
- hourly: env.DEFAULT_LIMIT,
39
- burst: env.DEFAULT_BURST,
40
- tokens: [],
41
- },
42
- };
43
-
44
- export const globalLimit = env.GLOBAL_LIMIT; // 50 000/h
45
-
46
- /**
47
- * Returns the plan matching a bearer token, or 'default'.
48
- * Returns null if the token is provided but invalid.
49
- */
50
- export function getPlan(token: string): { name: string; plan: Plan } | null {
51
- if (!token) return { name: 'default', plan: plans.default! };
52
- if (token === 'undefined') return null;
53
-
54
- for (const [name, plan] of Object.entries(plans)) {
55
- if (name === 'default') continue;
56
- if (plan.tokens.includes('undefined')) continue;
57
- if (plan.tokens.includes(token)) return { name, plan };
58
- }
59
-
60
- return null;
61
- }
@@ -1,121 +0,0 @@
1
- import * as apiv3 from '../modules/v3.js';
2
- import * as apiv4 from '../modules/v4.js';
3
-
4
- export interface Endpoint {
5
- name: string;
6
- path?: string;
7
- children?: Record<string, string>;
8
- }
9
-
10
- export interface VersionConfig {
11
- endpoints: {
12
- get: Endpoint[];
13
- post: Endpoint[];
14
- patch?: Endpoint[];
15
- delete?: Endpoint[];
16
- };
17
- modules: typeof apiv3 | typeof apiv4;
18
- }
19
-
20
- /**
21
- * Merges a base list of endpoints with additions, deduplicating by `name`.
22
- * If an addition has the same name as a base entry, it overrides it.
23
- */
24
- const merge = (base: Endpoint[], additions: Endpoint[]): Endpoint[] => {
25
- const map = new Map(base.map((e) => [e.name, e]));
26
- for (const e of additions) map.set(e.name, e);
27
- return [...map.values()];
28
- };
29
-
30
- const v1 = {
31
- get: [
32
- { name: 'algorithms', path: '/algorithms?method={algorithm}&value={value}(&value2={value2})' },
33
- { name: 'captcha', path: '/captcha?text={text}' },
34
- { name: 'color', path: '/color' },
35
- { name: 'convert', path: '/convert?value={value}&from={unit}&to={unit}' },
36
- { name: 'domain', path: '/domain' },
37
- { name: 'infos', path: '/infos' },
38
- { name: 'personal', path: '/personal' },
39
- { name: 'qrcode', path: '/qrcode?url={URL}' },
40
- { name: 'username', path: '/username' },
41
- { name: 'website', path: '/website' },
42
- ],
43
- post: [{ name: 'token', path: '/token' }],
44
- };
45
-
46
- const v2 = {
47
- get: merge(v1.get, [{ name: 'chat', path: '/chat' }]),
48
- post: merge(v1.post, [
49
- {
50
- name: 'chat',
51
- children: {
52
- chat: '/chat',
53
- private: '/chat/private',
54
- } as Record<string, string>,
55
- },
56
- { name: 'hash', path: '/hash' },
57
- {
58
- name: 'tic_tac_toe',
59
- children: {
60
- tic_tac_toe: '/tic-tac-toe',
61
- fetch: '/tic-tac-toe/fetch',
62
- list: '/tic-tac-toe/list',
63
- } as Record<string, string>,
64
- },
65
- ]),
66
- };
67
-
68
- const v3 = {
69
- get: merge(v2.get, [
70
- { name: 'levenshtein', path: '/levenshtein?str1={string}&str2={string}' },
71
- {
72
- name: 'time',
73
- path: '/time(?type={live|random|countdown}&target={date}&start={timestamp}&end={timestamp}&format={format}&timezone={timezone})',
74
- },
75
- ]),
76
- post: merge(v2.post, [{ name: 'hyperplanning', path: '/hyperplanning' }]),
77
- };
78
-
79
- const v4 = {
80
- get: merge(v3.get, [
81
- { name: 'address', path: '/address(&country={code}&count={n})' },
82
- { name: 'agent', path: '/agent(&ua={string})' },
83
- {
84
- name: 'captcha',
85
- path: '/captcha(&text={text}&length={n}&width={px}&height={px}&noise={low|medium|high}&bg={hex}&color={hex})',
86
- },
87
- { name: 'color', path: '/color(&hex={hex})' },
88
- { name: 'convert', path: '/convert?value={value}&from={unit}&to={unit}' },
89
- { name: 'cron', path: '/cron?expr={expression}(&count={n}&from={date}&timezone={timezone})' },
90
- { name: 'dice', path: '/dice?roll={NdX+M}' },
91
- { name: 'encode', path: '/encode?method={method}&text={text}(&shift={shift})' },
92
- { name: 'geo', path: '/geo?lat1={lat}&lon1={lon}&lat2={lat}&lon2={lon}' },
93
- { name: 'headers', path: '/headers(&filter={header1,header2})' },
94
- { name: 'ip', path: '/ip(&address={ip})' },
95
- { name: 'palette', path: '/palette?color={#hex}&type={type}' },
96
- {
97
- name: 'password',
98
- path: '/password(&type={random|passphrase}&length={n}&uppercase={bool}&lowercase={bool}&digits={bool}&symbols={bool}&exclude={chars}&count={n}&separator={char})',
99
- },
100
- {
101
- name: 'placeholder',
102
- path: '/placeholder?type={image|skeleton}&width={w}&height={h}(&bg={hex}&color={hex}&text={text}&rows={n}&avatar={bool})',
103
- },
104
- {
105
- name: 'qrcode',
106
- path: '/qrcode?url={URL}(&size={px}&margin={n}&correction={L|M|Q|H}&dark={hex}&light={hex}&icon={URL}&iconSize={px}&iconPadding={px}&iconRadius={px}&format={png|base64})',
107
- },
108
- { name: 'regex', path: '/regex?pattern={regex}&text={string}(&flags={flags})' },
109
- { name: 'statistics', path: '/statistics?values={n1,n2,n3,...}' },
110
- { name: 'text', path: '/text?method={method}(&value={value}&type={type}&count={count}&lang={lang})' },
111
- { name: 'validate', path: '/validate?type={type}&value={value}' },
112
- ]),
113
- post: [...v3.post],
114
- };
115
-
116
- export const versions: Record<string, VersionConfig> = {
117
- v1: { endpoints: v1, modules: apiv3 },
118
- v2: { endpoints: v2, modules: apiv3 },
119
- v3: { endpoints: v3, modules: apiv3 },
120
- v4: { endpoints: v4, modules: apiv4 },
121
- };