@seip/bluebird-js 0.0.1 → 0.1.1
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/.env_example +53 -53
- package/AGENTS.md +426 -403
- package/LICENSE +1 -1
- package/README.md +292 -285
- package/app/routes/api.js +50 -50
- package/app/routes/web.js +55 -53
- package/app/views/about.js +63 -0
- package/app/views/dashboard.js +147 -0
- package/app/views/index.js +80 -0
- package/app/views/layouts/main/view.js +81 -0
- package/app/views/legal/terms.html +19 -0
- package/app/views/login.js +80 -0
- package/core/app.d.ts +18 -18
- package/core/app.js +684 -644
- package/core/auth.d.ts +13 -13
- package/core/auth.js +326 -326
- package/core/cache.d.ts +17 -17
- package/core/cache.js +475 -475
- package/core/cli/doctor.js +287 -287
- package/core/cli/ecosystem.js +162 -162
- package/core/cli/init.js +779 -779
- package/core/cli/migrate.js +541 -541
- package/core/cli/model.js +66 -66
- package/core/cli/nginx.js +199 -199
- package/core/cli/route.js +120 -120
- package/core/cli/view.js +55 -36
- package/core/config.d.ts +3 -3
- package/core/config.js +111 -111
- package/core/csrf.d.ts +3 -3
- package/core/csrf.js +114 -114
- package/core/database.d.ts +15 -15
- package/core/database.js +636 -636
- package/core/debug.d.ts +3 -3
- package/core/debug.js +249 -249
- package/core/hash.d.ts +3 -3
- package/core/hash.js +194 -194
- package/core/html.d.ts +42 -0
- package/core/html.js +217 -0
- package/core/index.d.ts +1176 -1071
- package/core/logger.d.ts +3 -3
- package/core/logger.js +127 -124
- package/core/middleware.d.ts +3 -3
- package/core/middleware.js +28 -28
- package/core/model.d.ts +19 -19
- package/core/model.js +600 -600
- package/core/queue.d.ts +13 -13
- package/core/queue.js +172 -172
- package/core/ratelimit.d.ts +3 -3
- package/core/ratelimit.js +145 -145
- package/core/redis.d.ts +21 -21
- package/core/redis.js +230 -230
- package/core/render-cache.js +212 -0
- package/core/render.d.ts +3 -3
- package/core/render.js +199 -555
- package/core/router.d.ts +3 -3
- package/core/router.js +171 -171
- package/core/seo.d.ts +3 -3
- package/core/seo.js +106 -106
- package/core/swagger.d.ts +3 -3
- package/core/swagger.js +60 -60
- package/core/upload.d.ts +13 -13
- package/core/upload.js +102 -102
- package/core/util/colors.js +82 -82
- package/core/validate.d.ts +15 -15
- package/core/validate.js +364 -364
- package/core/view-loader.js +162 -0
- package/core/vite.d.ts +3 -3
- package/core/vite.js +145 -145
- package/core/ws.d.ts +13 -13
- package/core/ws.js +245 -245
- package/index.js +18 -18
- package/jsconfig.json +15 -15
- package/package.json +85 -86
- package/production.md +273 -273
- package/public/css/bluebird.min.css +1 -1
- package/public/js/bluebird-client.js +1780 -1662
- package/public/js/bluebird.min.js +1072 -1072
- package/app/views/about.html +0 -161
- package/app/views/dashboard.html +0 -140
- package/app/views/index.html +0 -150
- package/app/views/login.html +0 -144
package/core/swagger.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Swagger and OpenAPI documentation integration module.
|
|
3
|
-
* Dynamically loads swagger-ui-express and swagger-jsdoc when enabled.
|
|
4
|
-
*/
|
|
5
|
-
class Swagger {
|
|
6
|
-
/**
|
|
7
|
-
* Initializes Swagger UI documentation on the Express application.
|
|
8
|
-
* @param {import('express').Application} app - Express application instance.
|
|
9
|
-
* @param {Object} [options={}] - Configuration options.
|
|
10
|
-
* @param {string} [options.route="/docs"] - HTTP route for documentation.
|
|
11
|
-
* @param {Object} [options.info={}] - OpenAPI info object.
|
|
12
|
-
* @param {string[]} [options.apis=[]] - Glob paths for JSDoc documentation files.
|
|
13
|
-
* @returns {Promise<boolean>} Resolves to true if documentation was mounted.
|
|
14
|
-
*/
|
|
15
|
-
static async init(app, options = {}) {
|
|
16
|
-
const route = options.route || "/docs";
|
|
17
|
-
const apis = options.apis || ["./app/routes/*.js", "./app/routes/*.ts"];
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const [{ default: swaggerUi }, { default: swaggerJsdoc }] = await Promise.all([
|
|
21
|
-
import("swagger-ui-express"),
|
|
22
|
-
import("swagger-jsdoc"),
|
|
23
|
-
]);
|
|
24
|
-
|
|
25
|
-
const swaggerDefinition = {
|
|
26
|
-
openapi: "3.0.0",
|
|
27
|
-
info: {
|
|
28
|
-
title: options.info?.title || "Blue Bird API",
|
|
29
|
-
version: options.info?.version || "1.0.0",
|
|
30
|
-
description: options.info?.description || "Blue Bird Framework API Documentation",
|
|
31
|
-
},
|
|
32
|
-
servers: [
|
|
33
|
-
{
|
|
34
|
-
url: options.url || "http://localhost:3000",
|
|
35
|
-
description: "API Server",
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const swaggerSpec = swaggerJsdoc({
|
|
41
|
-
swaggerDefinition,
|
|
42
|
-
apis,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
app.use(route, swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
|
46
|
-
app.get(`${route}/json`, (req, res) => {
|
|
47
|
-
res.setHeader("Content-Type", "application/json");
|
|
48
|
-
res.send(swaggerSpec);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return true;
|
|
52
|
-
} catch {
|
|
53
|
-
console.warn("[SWAGGER WARN] 'swagger-ui-express' or 'swagger-jsdoc' is not installed. Run: npx blue-bird add swagger");
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { Swagger };
|
|
60
|
-
export default Swagger;
|
|
1
|
+
/**
|
|
2
|
+
* Swagger and OpenAPI documentation integration module.
|
|
3
|
+
* Dynamically loads swagger-ui-express and swagger-jsdoc when enabled.
|
|
4
|
+
*/
|
|
5
|
+
class Swagger {
|
|
6
|
+
/**
|
|
7
|
+
* Initializes Swagger UI documentation on the Express application.
|
|
8
|
+
* @param {import('express').Application} app - Express application instance.
|
|
9
|
+
* @param {Object} [options={}] - Configuration options.
|
|
10
|
+
* @param {string} [options.route="/docs"] - HTTP route for documentation.
|
|
11
|
+
* @param {Object} [options.info={}] - OpenAPI info object.
|
|
12
|
+
* @param {string[]} [options.apis=[]] - Glob paths for JSDoc documentation files.
|
|
13
|
+
* @returns {Promise<boolean>} Resolves to true if documentation was mounted.
|
|
14
|
+
*/
|
|
15
|
+
static async init(app, options = {}) {
|
|
16
|
+
const route = options.route || "/docs";
|
|
17
|
+
const apis = options.apis || ["./app/routes/*.js", "./app/routes/*.ts"];
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const [{ default: swaggerUi }, { default: swaggerJsdoc }] = await Promise.all([
|
|
21
|
+
import("swagger-ui-express"),
|
|
22
|
+
import("swagger-jsdoc"),
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
const swaggerDefinition = {
|
|
26
|
+
openapi: "3.0.0",
|
|
27
|
+
info: {
|
|
28
|
+
title: options.info?.title || "Blue Bird API",
|
|
29
|
+
version: options.info?.version || "1.0.0",
|
|
30
|
+
description: options.info?.description || "Blue Bird Framework API Documentation",
|
|
31
|
+
},
|
|
32
|
+
servers: [
|
|
33
|
+
{
|
|
34
|
+
url: options.url || "http://localhost:3000",
|
|
35
|
+
description: "API Server",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const swaggerSpec = swaggerJsdoc({
|
|
41
|
+
swaggerDefinition,
|
|
42
|
+
apis,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
app.use(route, swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
|
46
|
+
app.get(`${route}/json`, (req, res) => {
|
|
47
|
+
res.setHeader("Content-Type", "application/json");
|
|
48
|
+
res.send(swaggerSpec);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return true;
|
|
52
|
+
} catch {
|
|
53
|
+
console.warn("[SWAGGER WARN] 'swagger-ui-express' or 'swagger-jsdoc' is not installed. Run: npx blue-bird add swagger");
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { Swagger };
|
|
60
|
+
export default Swagger;
|
package/core/upload.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Upload,
|
|
3
|
-
UploadDiskOptions,
|
|
4
|
-
UploadMiddleware,
|
|
5
|
-
UploadedFile,
|
|
6
|
-
} from "./index.js";
|
|
7
|
-
export default Upload;
|
|
8
|
-
export {
|
|
9
|
-
Upload,
|
|
10
|
-
UploadDiskOptions,
|
|
11
|
-
UploadMiddleware,
|
|
12
|
-
UploadedFile,
|
|
13
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
Upload,
|
|
3
|
+
UploadDiskOptions,
|
|
4
|
+
UploadMiddleware,
|
|
5
|
+
UploadedFile,
|
|
6
|
+
} from "./index.js";
|
|
7
|
+
export default Upload;
|
|
8
|
+
export {
|
|
9
|
+
Upload,
|
|
10
|
+
UploadDiskOptions,
|
|
11
|
+
UploadMiddleware,
|
|
12
|
+
UploadedFile,
|
|
13
|
+
};
|
package/core/upload.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import Config from "./config.js";
|
|
4
|
-
|
|
5
|
-
const __dirname = Config.dirname();
|
|
6
|
-
const props = Config.props();
|
|
7
|
-
|
|
8
|
-
let multer = null;
|
|
9
|
-
try {
|
|
10
|
-
multer = (await import("multer")).default || (await import("multer"));
|
|
11
|
-
} catch {}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Upload helper to manage file uploads using multer.
|
|
15
|
-
*/
|
|
16
|
-
class Upload {
|
|
17
|
-
/**
|
|
18
|
-
* Asserts that the multer package is available.
|
|
19
|
-
* @private
|
|
20
|
-
*/
|
|
21
|
-
static _ensureMulter() {
|
|
22
|
-
if (!multer) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
"[UPLOAD ERROR] 'multer' package is not installed. Install it with: npm install multer or npx blue-bird add upload",
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Configures storage for uploaded files.
|
|
31
|
-
* @param {string} folder - The destination folder within the static path.
|
|
32
|
-
* @returns {import('multer').StorageEngine}
|
|
33
|
-
* @example
|
|
34
|
-
* const storage = Upload.storage("uploads");
|
|
35
|
-
*/
|
|
36
|
-
static storage(folder = "uploads") {
|
|
37
|
-
this._ensureMulter();
|
|
38
|
-
const dest = path.join(__dirname, props.static.path, folder);
|
|
39
|
-
|
|
40
|
-
if (!fs.existsSync(dest)) {
|
|
41
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return multer.diskStorage({
|
|
45
|
-
destination: (req, file, cb) => {
|
|
46
|
-
cb(null, dest);
|
|
47
|
-
},
|
|
48
|
-
filename: (req, file, cb) => {
|
|
49
|
-
const uniqueSuffix =
|
|
50
|
-
Date.now() + "-" + Math.round(Math.random() * 1e9);
|
|
51
|
-
cb(null, uniqueSuffix + path.extname(file.originalname));
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Returns a multer instance for single or multiple file uploads.
|
|
58
|
-
* @param {Object} options - Multer options.
|
|
59
|
-
* @param {string} [options.folder='uploads'] - Destination folder.
|
|
60
|
-
* @param {number} [options.fileSize=5000000] - Max file size in bytes (default 5MB).
|
|
61
|
-
* @param {Array<string>} [options.allowedTypes=[]] - Allowed mime types (e.g. ['image/png', 'image/jpeg']).
|
|
62
|
-
* @returns {import('multer').Multer}
|
|
63
|
-
* @example
|
|
64
|
-
* const upload = Upload.disk({ folder: "uploads", fileSize: 5000000, allowedTypes: ["image/png", "image/jpeg"] });
|
|
65
|
-
*/
|
|
66
|
-
static disk(options = {}) {
|
|
67
|
-
this._ensureMulter();
|
|
68
|
-
const {
|
|
69
|
-
folder = "uploads",
|
|
70
|
-
fileSize = 5000000,
|
|
71
|
-
allowedTypes = [],
|
|
72
|
-
} = options;
|
|
73
|
-
|
|
74
|
-
return multer({
|
|
75
|
-
storage: this.storage(folder),
|
|
76
|
-
limits: { fileSize },
|
|
77
|
-
fileFilter: (req, file, cb) => {
|
|
78
|
-
if (allowedTypes.length > 0 && !allowedTypes.includes(file.mimetype)) {
|
|
79
|
-
return cb(new Error("File type not allowed"), false);
|
|
80
|
-
}
|
|
81
|
-
cb(null, true);
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Helper to get the public URL of an uploaded file.
|
|
88
|
-
* @param {string} filename - The name of the file.
|
|
89
|
-
* @param {string} [folder='uploads'] - The folder where the file is stored.
|
|
90
|
-
* @returns {string} The full public URL.
|
|
91
|
-
* @example
|
|
92
|
-
* const url = Upload.url("file.jpg", "uploads");
|
|
93
|
-
*/
|
|
94
|
-
static url(filename, folder = "uploads") {
|
|
95
|
-
const appUrl = props.appUrl ?? `${props.host}:${props.port}`;
|
|
96
|
-
return `${appUrl}/${folder}/${filename}`;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export { Upload };
|
|
101
|
-
export default Upload;
|
|
102
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import Config from "./config.js";
|
|
4
|
+
|
|
5
|
+
const __dirname = Config.dirname();
|
|
6
|
+
const props = Config.props();
|
|
7
|
+
|
|
8
|
+
let multer = null;
|
|
9
|
+
try {
|
|
10
|
+
multer = (await import("multer")).default || (await import("multer"));
|
|
11
|
+
} catch {}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Upload helper to manage file uploads using multer.
|
|
15
|
+
*/
|
|
16
|
+
class Upload {
|
|
17
|
+
/**
|
|
18
|
+
* Asserts that the multer package is available.
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
static _ensureMulter() {
|
|
22
|
+
if (!multer) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
"[UPLOAD ERROR] 'multer' package is not installed. Install it with: npm install multer or npx blue-bird add upload",
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Configures storage for uploaded files.
|
|
31
|
+
* @param {string} folder - The destination folder within the static path.
|
|
32
|
+
* @returns {import('multer').StorageEngine}
|
|
33
|
+
* @example
|
|
34
|
+
* const storage = Upload.storage("uploads");
|
|
35
|
+
*/
|
|
36
|
+
static storage(folder = "uploads") {
|
|
37
|
+
this._ensureMulter();
|
|
38
|
+
const dest = path.join(__dirname, props.static.path, folder);
|
|
39
|
+
|
|
40
|
+
if (!fs.existsSync(dest)) {
|
|
41
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return multer.diskStorage({
|
|
45
|
+
destination: (req, file, cb) => {
|
|
46
|
+
cb(null, dest);
|
|
47
|
+
},
|
|
48
|
+
filename: (req, file, cb) => {
|
|
49
|
+
const uniqueSuffix =
|
|
50
|
+
Date.now() + "-" + Math.round(Math.random() * 1e9);
|
|
51
|
+
cb(null, uniqueSuffix + path.extname(file.originalname));
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Returns a multer instance for single or multiple file uploads.
|
|
58
|
+
* @param {Object} options - Multer options.
|
|
59
|
+
* @param {string} [options.folder='uploads'] - Destination folder.
|
|
60
|
+
* @param {number} [options.fileSize=5000000] - Max file size in bytes (default 5MB).
|
|
61
|
+
* @param {Array<string>} [options.allowedTypes=[]] - Allowed mime types (e.g. ['image/png', 'image/jpeg']).
|
|
62
|
+
* @returns {import('multer').Multer}
|
|
63
|
+
* @example
|
|
64
|
+
* const upload = Upload.disk({ folder: "uploads", fileSize: 5000000, allowedTypes: ["image/png", "image/jpeg"] });
|
|
65
|
+
*/
|
|
66
|
+
static disk(options = {}) {
|
|
67
|
+
this._ensureMulter();
|
|
68
|
+
const {
|
|
69
|
+
folder = "uploads",
|
|
70
|
+
fileSize = 5000000,
|
|
71
|
+
allowedTypes = [],
|
|
72
|
+
} = options;
|
|
73
|
+
|
|
74
|
+
return multer({
|
|
75
|
+
storage: this.storage(folder),
|
|
76
|
+
limits: { fileSize },
|
|
77
|
+
fileFilter: (req, file, cb) => {
|
|
78
|
+
if (allowedTypes.length > 0 && !allowedTypes.includes(file.mimetype)) {
|
|
79
|
+
return cb(new Error("File type not allowed"), false);
|
|
80
|
+
}
|
|
81
|
+
cb(null, true);
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Helper to get the public URL of an uploaded file.
|
|
88
|
+
* @param {string} filename - The name of the file.
|
|
89
|
+
* @param {string} [folder='uploads'] - The folder where the file is stored.
|
|
90
|
+
* @returns {string} The full public URL.
|
|
91
|
+
* @example
|
|
92
|
+
* const url = Upload.url("file.jpg", "uploads");
|
|
93
|
+
*/
|
|
94
|
+
static url(filename, folder = "uploads") {
|
|
95
|
+
const appUrl = props.appUrl ?? `${props.host}:${props.port}`;
|
|
96
|
+
return `${appUrl}/${folder}/${filename}`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { Upload };
|
|
101
|
+
export default Upload;
|
|
102
|
+
|
package/core/util/colors.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { styleText } from "node:util";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ANSI color formatting utilities powered by Node.js native styleText.
|
|
5
|
-
* Provides a lightweight, zero-dependency alternative to chalk.
|
|
6
|
-
*/
|
|
7
|
-
const colors = {
|
|
8
|
-
/**
|
|
9
|
-
* Applies bold formatting.
|
|
10
|
-
* @param {string|number} text
|
|
11
|
-
* @returns {string}
|
|
12
|
-
*/
|
|
13
|
-
bold: (text) => styleText("bold", String(text)),
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Applies green color.
|
|
17
|
-
* @param {string|number} text
|
|
18
|
-
* @returns {string}
|
|
19
|
-
*/
|
|
20
|
-
green: (text) => styleText("green", String(text)),
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Applies red color.
|
|
24
|
-
* @param {string|number} text
|
|
25
|
-
* @returns {string}
|
|
26
|
-
*/
|
|
27
|
-
red: (text) => styleText("red", String(text)),
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Applies blue color.
|
|
31
|
-
* @param {string|number} text
|
|
32
|
-
* @returns {string}
|
|
33
|
-
*/
|
|
34
|
-
blue: (text) => styleText("blue", String(text)),
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Applies yellow color.
|
|
38
|
-
* @param {string|number} text
|
|
39
|
-
* @returns {string}
|
|
40
|
-
*/
|
|
41
|
-
yellow: (text) => styleText("yellow", String(text)),
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Applies cyan color.
|
|
45
|
-
* @param {string|number} text
|
|
46
|
-
* @returns {string}
|
|
47
|
-
*/
|
|
48
|
-
cyan: (text) => styleText("cyan", String(text)),
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Applies magenta color.
|
|
52
|
-
* @param {string|number} text
|
|
53
|
-
* @returns {string}
|
|
54
|
-
*/
|
|
55
|
-
magenta: (text) => styleText("magenta", String(text)),
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Applies gray color.
|
|
59
|
-
* @param {string|number} text
|
|
60
|
-
* @returns {string}
|
|
61
|
-
*/
|
|
62
|
-
gray: (text) => styleText("gray", String(text)),
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Applies white color.
|
|
66
|
-
* @param {string|number} text
|
|
67
|
-
* @returns {string}
|
|
68
|
-
*/
|
|
69
|
-
white: (text) => styleText("white", String(text)),
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Bold color modifier functions.
|
|
74
|
-
*/
|
|
75
|
-
colors.bold.green = (text) => styleText(["bold", "green"], String(text));
|
|
76
|
-
colors.bold.red = (text) => styleText(["bold", "red"], String(text));
|
|
77
|
-
colors.bold.blue = (text) => styleText(["bold", "blue"], String(text));
|
|
78
|
-
colors.bold.cyan = (text) => styleText(["bold", "cyan"], String(text));
|
|
79
|
-
colors.bold.yellow = (text) => styleText(["bold", "yellow"], String(text));
|
|
80
|
-
colors.bold.magenta = (text) => styleText(["bold", "magenta"], String(text));
|
|
81
|
-
|
|
82
|
-
export default colors;
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ANSI color formatting utilities powered by Node.js native styleText.
|
|
5
|
+
* Provides a lightweight, zero-dependency alternative to chalk.
|
|
6
|
+
*/
|
|
7
|
+
const colors = {
|
|
8
|
+
/**
|
|
9
|
+
* Applies bold formatting.
|
|
10
|
+
* @param {string|number} text
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
bold: (text) => styleText("bold", String(text)),
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Applies green color.
|
|
17
|
+
* @param {string|number} text
|
|
18
|
+
* @returns {string}
|
|
19
|
+
*/
|
|
20
|
+
green: (text) => styleText("green", String(text)),
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Applies red color.
|
|
24
|
+
* @param {string|number} text
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
red: (text) => styleText("red", String(text)),
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Applies blue color.
|
|
31
|
+
* @param {string|number} text
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
blue: (text) => styleText("blue", String(text)),
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Applies yellow color.
|
|
38
|
+
* @param {string|number} text
|
|
39
|
+
* @returns {string}
|
|
40
|
+
*/
|
|
41
|
+
yellow: (text) => styleText("yellow", String(text)),
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Applies cyan color.
|
|
45
|
+
* @param {string|number} text
|
|
46
|
+
* @returns {string}
|
|
47
|
+
*/
|
|
48
|
+
cyan: (text) => styleText("cyan", String(text)),
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Applies magenta color.
|
|
52
|
+
* @param {string|number} text
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
magenta: (text) => styleText("magenta", String(text)),
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Applies gray color.
|
|
59
|
+
* @param {string|number} text
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
gray: (text) => styleText("gray", String(text)),
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Applies white color.
|
|
66
|
+
* @param {string|number} text
|
|
67
|
+
* @returns {string}
|
|
68
|
+
*/
|
|
69
|
+
white: (text) => styleText("white", String(text)),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Bold color modifier functions.
|
|
74
|
+
*/
|
|
75
|
+
colors.bold.green = (text) => styleText(["bold", "green"], String(text));
|
|
76
|
+
colors.bold.red = (text) => styleText(["bold", "red"], String(text));
|
|
77
|
+
colors.bold.blue = (text) => styleText(["bold", "blue"], String(text));
|
|
78
|
+
colors.bold.cyan = (text) => styleText(["bold", "cyan"], String(text));
|
|
79
|
+
colors.bold.yellow = (text) => styleText(["bold", "yellow"], String(text));
|
|
80
|
+
colors.bold.magenta = (text) => styleText(["bold", "magenta"], String(text));
|
|
81
|
+
|
|
82
|
+
export default colors;
|
package/core/validate.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Validator,
|
|
3
|
-
ValidationRule,
|
|
4
|
-
ValidationSchema,
|
|
5
|
-
ValidationError,
|
|
6
|
-
ValidationResult,
|
|
7
|
-
} from "./index.js";
|
|
8
|
-
export default Validator;
|
|
9
|
-
export {
|
|
10
|
-
Validator,
|
|
11
|
-
ValidationRule,
|
|
12
|
-
ValidationSchema,
|
|
13
|
-
ValidationError,
|
|
14
|
-
ValidationResult,
|
|
15
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
Validator,
|
|
3
|
+
ValidationRule,
|
|
4
|
+
ValidationSchema,
|
|
5
|
+
ValidationError,
|
|
6
|
+
ValidationResult,
|
|
7
|
+
} from "./index.js";
|
|
8
|
+
export default Validator;
|
|
9
|
+
export {
|
|
10
|
+
Validator,
|
|
11
|
+
ValidationRule,
|
|
12
|
+
ValidationSchema,
|
|
13
|
+
ValidationError,
|
|
14
|
+
ValidationResult,
|
|
15
|
+
};
|