@20syldev/api 5.6.0 → 5.7.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/.prettierignore +5 -0
- package/README.md +204 -80
- package/dist/app.d.ts +2 -0
- package/dist/config/env.d.ts +21 -0
- package/dist/config/env.js +10 -2
- package/dist/config/env.js.map +1 -1
- package/dist/config/plans.d.ts +26 -0
- package/dist/config/versions.d.ts +18 -0
- package/dist/constants.d.ts +39 -0
- package/dist/constants.js +0 -1
- package/dist/constants.js.map +1 -1
- package/dist/middleware/cors.d.ts +2 -0
- package/dist/middleware/cors.js +2 -1
- package/dist/middleware/cors.js.map +1 -1
- package/dist/middleware/error.d.ts +4 -0
- package/dist/middleware/json.d.ts +2 -0
- package/dist/middleware/logger.d.ts +26 -0
- package/dist/middleware/logger.js +34 -1
- package/dist/middleware/logger.js.map +1 -1
- package/dist/middleware/ratelimit.d.ts +2 -0
- package/dist/middleware/version.d.ts +3 -0
- package/dist/middleware/version.js +2 -2
- package/dist/middleware/version.js.map +1 -1
- package/dist/modules/v3/algorithms.d.ts +82 -0
- package/dist/modules/v3/captcha.d.ts +8 -0
- package/dist/modules/v3/chat.d.ts +9 -0
- package/dist/modules/v3/chat.js +3 -3
- package/dist/modules/v3/chat.js.map +1 -1
- package/dist/modules/v3/color.d.ts +6 -0
- package/dist/modules/v3/convert.d.ts +10 -0
- package/dist/modules/v3/domain.d.ts +6 -0
- package/dist/modules/v3/hash.d.ts +8 -0
- package/dist/modules/v3/hyperplanning.d.ts +9 -0
- package/dist/modules/v3/levenshtein.d.ts +9 -0
- package/dist/modules/v3/personal.d.ts +6 -0
- package/dist/modules/v3/qrcode.d.ts +8 -0
- package/dist/modules/v3/tic_tac_toe.d.ts +9 -0
- package/dist/modules/v3/tic_tac_toe.js +3 -3
- package/dist/modules/v3/tic_tac_toe.js.map +1 -1
- package/dist/modules/v3/time.d.ts +12 -0
- package/dist/modules/v3/token.d.ts +9 -0
- package/dist/modules/v3/username.d.ts +6 -0
- package/dist/modules/v3/utils.d.ts +50 -0
- package/dist/modules/v3.d.ts +15 -0
- package/dist/modules/v4/address.d.ts +20 -0
- package/dist/modules/v4/agent.d.ts +30 -0
- package/dist/modules/v4/algorithms.d.ts +90 -0
- package/dist/modules/v4/avatar.d.ts +23 -0
- package/dist/modules/v4/barcode.d.ts +27 -0
- package/dist/modules/v4/captcha.d.ts +22 -0
- package/dist/modules/v4/chat.d.ts +21 -0
- package/dist/modules/v4/chat.js +3 -3
- package/dist/modules/v4/chat.js.map +1 -1
- package/dist/modules/v4/color.d.ts +16 -0
- package/dist/modules/v4/convert.d.ts +15 -0
- package/dist/modules/v4/credit.d.ts +22 -0
- package/dist/modules/v4/cron.d.ts +17 -0
- package/dist/modules/v4/dice.d.ts +16 -0
- package/dist/modules/v4/domain.d.ts +6 -0
- package/dist/modules/v4/encode.d.ts +81 -0
- package/dist/modules/v4/geo.d.ts +30 -0
- package/dist/modules/v4/hash.d.ts +15 -0
- package/dist/modules/v4/hyperplanning.d.ts +19 -0
- package/dist/modules/v4/ip.d.ts +19 -0
- package/dist/modules/v4/levenshtein.d.ts +13 -0
- package/dist/modules/v4/palette.d.ts +19 -0
- package/dist/modules/v4/password.d.ts +25 -0
- package/dist/modules/v4/personal.d.ts +6 -0
- package/dist/modules/v4/placeholder.d.ts +30 -0
- package/dist/modules/v4/qrcode.d.ts +25 -0
- package/dist/modules/v4/regex.d.ts +23 -0
- package/dist/modules/v4/statistics.d.ts +20 -0
- package/dist/modules/v4/text.d.ts +43 -0
- package/dist/modules/v4/tic_tac_toe.d.ts +19 -0
- package/dist/modules/v4/tic_tac_toe.js +3 -3
- package/dist/modules/v4/tic_tac_toe.js.map +1 -1
- package/dist/modules/v4/time.d.ts +15 -0
- package/dist/modules/v4/token.d.ts +9 -0
- package/dist/modules/v4/username.d.ts +6 -0
- package/dist/modules/v4/validate.d.ts +34 -0
- package/dist/modules/v4.d.ts +32 -0
- package/dist/modules/v5/address.d.ts +5 -0
- package/dist/modules/v5/algorithms.d.ts +9 -0
- package/dist/modules/v5/asymmetric.d.ts +26 -0
- package/dist/modules/v5/barcode.d.ts +27 -0
- package/dist/modules/v5/case.d.ts +10 -0
- package/dist/modules/v5/chart.d.ts +53 -0
- package/dist/modules/v5/chat.d.ts +21 -0
- package/dist/modules/v5/chat.js +3 -3
- package/dist/modules/v5/chat.js.map +1 -1
- package/dist/modules/v5/csv.d.ts +29 -0
- package/dist/modules/v5/evaluate.d.ts +14 -0
- package/dist/modules/v5/jwt.d.ts +11 -0
- package/dist/modules/v5/matrix.d.ts +77 -0
- package/dist/modules/v5/otp.d.ts +30 -0
- package/dist/modules/v5/symmetric.d.ts +15 -0
- package/dist/modules/v5/text.d.ts +5 -0
- package/dist/modules/v5/tic_tac_toe.d.ts +19 -0
- package/dist/modules/v5/tic_tac_toe.js +3 -3
- package/dist/modules/v5/tic_tac_toe.js.map +1 -1
- package/dist/modules/v5/url.d.ts +18 -0
- package/dist/modules/v5/url.js +12 -3
- package/dist/modules/v5/url.js.map +1 -1
- package/dist/modules/v5.d.ts +17 -0
- package/dist/routes/delete.d.ts +2 -0
- package/dist/routes/delete.js +2 -2
- package/dist/routes/delete.js.map +1 -1
- package/dist/routes/get.d.ts +2 -0
- package/dist/routes/get.js +84 -85
- package/dist/routes/get.js.map +1 -1
- package/dist/routes/index.d.ts +2 -0
- package/dist/routes/index.js +8 -4
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/patch.d.ts +2 -0
- package/dist/routes/patch.js +1 -1
- package/dist/routes/patch.js.map +1 -1
- package/dist/routes/post.d.ts +2 -0
- package/dist/routes/post.js +32 -32
- package/dist/routes/post.js.map +1 -1
- package/dist/storage/index.d.ts +4 -0
- package/dist/types/storage.d.ts +49 -0
- package/dist/utils/colors.d.ts +44 -0
- package/dist/utils/helpers.d.ts +55 -0
- package/dist/utils/response.d.ts +9 -0
- package/dist/utils/response.js +2 -4
- package/dist/utils/response.js.map +1 -1
- package/package.json +17 -16
- package/robots.txt +74 -0
- package/src/favicon.ico +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks requests per user and throws if the rate limit is exceeded.
|
|
3
|
+
*
|
|
4
|
+
* @param rateLimits - Store of timestamps per user
|
|
5
|
+
* @param userId - Identifier of the requesting user
|
|
6
|
+
* @param timestamp - Current timestamp in milliseconds
|
|
7
|
+
* @param window - Time window in milliseconds
|
|
8
|
+
* @param limit - Maximum requests allowed in the window
|
|
9
|
+
* @returns false if within limits
|
|
10
|
+
* @throws Error if rate limit is exceeded
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkRateLimit(rateLimits: Record<string, number[]>, userId: string, timestamp: number, window?: number, limit?: number): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Parses a space-separated environment variable into an array.
|
|
15
|
+
*
|
|
16
|
+
* @param key - The environment variable name
|
|
17
|
+
* @returns The parsed array, or null if not set
|
|
18
|
+
*/
|
|
19
|
+
export declare function envList(key: string): string[] | null;
|
|
20
|
+
/**
|
|
21
|
+
* Formats a Date to ISO string without timezone suffix.
|
|
22
|
+
*
|
|
23
|
+
* @param date - The date to format
|
|
24
|
+
* @returns ISO-formatted string without trailing Z
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatDate(date: Date): string;
|
|
27
|
+
/**
|
|
28
|
+
* Generates a random IPv4 address.
|
|
29
|
+
*
|
|
30
|
+
* @returns A string in the format "X.X.X.X"
|
|
31
|
+
*/
|
|
32
|
+
export declare function genIP(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Returns a random element from an array.
|
|
35
|
+
*
|
|
36
|
+
* @param arr - The source array
|
|
37
|
+
* @returns A random element
|
|
38
|
+
*/
|
|
39
|
+
export declare function random<T>(arr: T[]): T;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a random integer between min and max (inclusive).
|
|
42
|
+
*
|
|
43
|
+
* @param min - Lower bound
|
|
44
|
+
* @param max - Upper bound
|
|
45
|
+
* @returns A random integer in [min, max]
|
|
46
|
+
*/
|
|
47
|
+
export declare function randomNumber(min: number, max: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a version string is at least the given minimum.
|
|
50
|
+
*
|
|
51
|
+
* @param version - Version string (e.g. "v4")
|
|
52
|
+
* @param min - Minimum version number
|
|
53
|
+
* @returns true if the version is >= min
|
|
54
|
+
*/
|
|
55
|
+
export declare function since(version: string, min: number): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Response } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Sends a standardized JSON error response.
|
|
4
|
+
*
|
|
5
|
+
* @param res - Express response object
|
|
6
|
+
* @param status - HTTP status code
|
|
7
|
+
* @param message - Error description
|
|
8
|
+
*/
|
|
9
|
+
export declare function error(res: Response, status: number, message: string): void;
|
package/dist/utils/response.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { STATUS_MESSAGES } from '../constants.js';
|
|
2
2
|
/**
|
|
3
3
|
* Sends a standardized JSON error response.
|
|
4
4
|
*
|
|
5
5
|
* @param res - Express response object
|
|
6
6
|
* @param status - HTTP status code
|
|
7
7
|
* @param message - Error description
|
|
8
|
-
* @param docPath - Optional documentation path appended to the base URL
|
|
9
8
|
*/
|
|
10
|
-
export function error(res, status, message
|
|
9
|
+
export function error(res, status, message) {
|
|
11
10
|
const body = {
|
|
12
11
|
message: STATUS_MESSAGES[status] ?? 'Error',
|
|
13
12
|
error: message,
|
|
14
|
-
documentation: docPath ? `${DOCS_URL}/${docPath}` : DOCS_URL,
|
|
15
13
|
status: String(status),
|
|
16
14
|
};
|
|
17
15
|
if (typeof res.jsonResponse === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/utils/response.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/utils/response.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,GAAa,EAAE,MAAc,EAAE,OAAe;IAChE,MAAM,IAAI,GAAG;QACT,OAAO,EAAE,eAAe,CAAC,MAAM,CAAC,IAAI,OAAO;QAC3C,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;KACzB,CAAC;IAEF,IAAI,OAAO,GAAG,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;QACzC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACJ,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;aACb,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC;aAC7C,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.
|
|
2
|
+
"version": "5.7.0",
|
|
3
3
|
"name": "@20syldev/api",
|
|
4
4
|
"description": "Node.js API with multiple features. Check the documentation at https://docs.sylvain.sh",
|
|
5
|
-
"main": "dist/
|
|
5
|
+
"main": "./dist/modules/v5.js",
|
|
6
|
+
"types": "./dist/modules/v5.d.ts",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"prepare": "tsc",
|
|
9
10
|
"dev": "tsx watch src/app.ts",
|
|
10
11
|
"start": "node dist/app.js",
|
|
11
12
|
"build": "tsc",
|
|
12
|
-
"check": "tsc --noEmit -p tsconfig.test.json && eslint src/ tests/",
|
|
13
|
-
"format": "prettier --write
|
|
14
|
-
"test": "NODE_ENV=test node --import tsx --test
|
|
15
|
-
"upgrade:minor": "npm upgrade",
|
|
16
|
-
"upgrade:major": "npx npm-check-updates -u && npm install"
|
|
13
|
+
"check": "tsc --noEmit -p tsconfig.test.json && eslint src/ tests/ && prettier --check .",
|
|
14
|
+
"format": "prettier --write . && eslint --fix src/ tests/",
|
|
15
|
+
"test": "NODE_ENV=test DOCS_URL=https://docs.example.test node --import tsx --test tests/unit/*.test.ts tests/integration/*.test.ts"
|
|
17
16
|
},
|
|
18
17
|
"engines": {
|
|
19
|
-
"node": ">=22.
|
|
18
|
+
"node": ">=22.12.0"
|
|
20
19
|
},
|
|
21
20
|
"exports": {
|
|
22
|
-
"./
|
|
23
|
-
"./
|
|
24
|
-
"./v3": "./dist/modules/v3.js",
|
|
25
|
-
"./
|
|
26
|
-
"./
|
|
21
|
+
".": { "types": "./dist/modules/v5.d.ts", "default": "./dist/modules/v5.js" },
|
|
22
|
+
"./server": { "types": "./dist/app.d.ts", "default": "./dist/app.js" },
|
|
23
|
+
"./v1": { "types": "./dist/modules/v3.d.ts", "default": "./dist/modules/v3.js" },
|
|
24
|
+
"./v2": { "types": "./dist/modules/v3.d.ts", "default": "./dist/modules/v3.js" },
|
|
25
|
+
"./v3": { "types": "./dist/modules/v3.d.ts", "default": "./dist/modules/v3.js" },
|
|
26
|
+
"./v4": { "types": "./dist/modules/v4.d.ts", "default": "./dist/modules/v4.js" },
|
|
27
|
+
"./v5": { "types": "./dist/modules/v5.d.ts", "default": "./dist/modules/v5.js" },
|
|
28
|
+
"./package.json": "./package.json"
|
|
27
29
|
},
|
|
28
30
|
"dependencies": {
|
|
29
31
|
"@20syldev/logger.ts": "^1.0.1",
|
|
32
|
+
"@types/express": "^5.0.0",
|
|
33
|
+
"@types/node": "^22.19.17",
|
|
30
34
|
"canvas": "^3.1.0",
|
|
31
35
|
"cors": "^2.8.5",
|
|
32
36
|
"dotenv": "^16.4.7",
|
|
@@ -39,14 +43,11 @@
|
|
|
39
43
|
"devDependencies": {
|
|
40
44
|
"@eslint/js": "^9.24.0",
|
|
41
45
|
"@types/cors": "^2.8.17",
|
|
42
|
-
"@types/express": "^5.0.0",
|
|
43
|
-
"@types/node": "^22.19.17",
|
|
44
46
|
"@types/qrcode": "^1.5.6",
|
|
45
47
|
"@types/uuid": "^10.0.0",
|
|
46
48
|
"eslint": "^9.24.0",
|
|
47
49
|
"eslint-config-prettier": "^10.1.1",
|
|
48
50
|
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
49
|
-
"npm-check-updates": "^18.0.1",
|
|
50
51
|
"prettier": "^3.5.3",
|
|
51
52
|
"tsx": "^4.19.0",
|
|
52
53
|
"typescript": "^5.7.0",
|
package/robots.txt
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
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/favicon.ico
ADDED
|
Binary file
|