@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.
Files changed (81) hide show
  1. package/.env_example +53 -53
  2. package/AGENTS.md +426 -403
  3. package/LICENSE +1 -1
  4. package/README.md +292 -285
  5. package/app/routes/api.js +50 -50
  6. package/app/routes/web.js +55 -53
  7. package/app/views/about.js +63 -0
  8. package/app/views/dashboard.js +147 -0
  9. package/app/views/index.js +80 -0
  10. package/app/views/layouts/main/view.js +81 -0
  11. package/app/views/legal/terms.html +19 -0
  12. package/app/views/login.js +80 -0
  13. package/core/app.d.ts +18 -18
  14. package/core/app.js +684 -644
  15. package/core/auth.d.ts +13 -13
  16. package/core/auth.js +326 -326
  17. package/core/cache.d.ts +17 -17
  18. package/core/cache.js +475 -475
  19. package/core/cli/doctor.js +287 -287
  20. package/core/cli/ecosystem.js +162 -162
  21. package/core/cli/init.js +779 -779
  22. package/core/cli/migrate.js +541 -541
  23. package/core/cli/model.js +66 -66
  24. package/core/cli/nginx.js +199 -199
  25. package/core/cli/route.js +120 -120
  26. package/core/cli/view.js +55 -36
  27. package/core/config.d.ts +3 -3
  28. package/core/config.js +111 -111
  29. package/core/csrf.d.ts +3 -3
  30. package/core/csrf.js +114 -114
  31. package/core/database.d.ts +15 -15
  32. package/core/database.js +636 -636
  33. package/core/debug.d.ts +3 -3
  34. package/core/debug.js +249 -249
  35. package/core/hash.d.ts +3 -3
  36. package/core/hash.js +194 -194
  37. package/core/html.d.ts +42 -0
  38. package/core/html.js +217 -0
  39. package/core/index.d.ts +1176 -1071
  40. package/core/logger.d.ts +3 -3
  41. package/core/logger.js +127 -124
  42. package/core/middleware.d.ts +3 -3
  43. package/core/middleware.js +28 -28
  44. package/core/model.d.ts +19 -19
  45. package/core/model.js +600 -600
  46. package/core/queue.d.ts +13 -13
  47. package/core/queue.js +172 -172
  48. package/core/ratelimit.d.ts +3 -3
  49. package/core/ratelimit.js +145 -145
  50. package/core/redis.d.ts +21 -21
  51. package/core/redis.js +230 -230
  52. package/core/render-cache.js +212 -0
  53. package/core/render.d.ts +3 -3
  54. package/core/render.js +199 -555
  55. package/core/router.d.ts +3 -3
  56. package/core/router.js +171 -171
  57. package/core/seo.d.ts +3 -3
  58. package/core/seo.js +106 -106
  59. package/core/swagger.d.ts +3 -3
  60. package/core/swagger.js +60 -60
  61. package/core/upload.d.ts +13 -13
  62. package/core/upload.js +102 -102
  63. package/core/util/colors.js +82 -82
  64. package/core/validate.d.ts +15 -15
  65. package/core/validate.js +364 -364
  66. package/core/view-loader.js +162 -0
  67. package/core/vite.d.ts +3 -3
  68. package/core/vite.js +145 -145
  69. package/core/ws.d.ts +13 -13
  70. package/core/ws.js +245 -245
  71. package/index.js +18 -18
  72. package/jsconfig.json +15 -15
  73. package/package.json +85 -86
  74. package/production.md +273 -273
  75. package/public/css/bluebird.min.css +1 -1
  76. package/public/js/bluebird-client.js +1780 -1662
  77. package/public/js/bluebird.min.js +1072 -1072
  78. package/app/views/about.html +0 -161
  79. package/app/views/dashboard.html +0 -140
  80. package/app/views/index.html +0 -150
  81. package/app/views/login.html +0 -144
package/core/logger.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Logger } from "./index.js";
2
- export default Logger;
3
- export { Logger };
1
+ import { Logger } from "./index.js";
2
+ export default Logger;
3
+ export { Logger };
package/core/logger.js CHANGED
@@ -1,124 +1,127 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import Config from "./config.js";
4
- import { getRedisClient } from "./cache.js";
5
-
6
- /**
7
- * Logger class for managing application logs by creating dated folders and log files.
8
- */
9
- class Logger {
10
- /**
11
- * Initializes the Logger instance and ensures the logs directory exists.
12
- */
13
- constructor() {
14
- this.folder = path.join(Config.userDataDir(), "logs");
15
- this._currentDay = null;
16
- this._currentDayFolder = null;
17
- try {
18
- if (!fs.existsSync(this.folder)) {
19
- fs.mkdirSync(this.folder, { recursive: true });
20
- }
21
- } catch {}
22
- }
23
-
24
- /**
25
- * Ensures and returns the path to the log folder for the current day.
26
- * Caches the folder path for the current day to avoid repeated fs checks.
27
- * @returns {string} The absolute path to the current day's log folder.
28
- */
29
- nowFolder() {
30
- const today = this.now();
31
-
32
- if (this._currentDay === today && this._currentDayFolder) {
33
- return this._currentDayFolder;
34
- }
35
-
36
- const folder = path.join(this.folder, today);
37
-
38
- if (!fs.existsSync(folder)) {
39
- fs.mkdirSync(folder, { recursive: true });
40
- }
41
-
42
- this._currentDay = today;
43
- this._currentDayFolder = folder;
44
- return folder;
45
- }
46
-
47
- /**
48
- * Gets the current date formatted as YYYY-MM-DD.
49
- * @returns {string} The formatted date string.
50
- */
51
- now() {
52
- return new Date().toISOString().split("T")[0];
53
- }
54
-
55
- /**
56
- * Logs a message to the specified log file or Redis list.
57
- * @private
58
- * @param {string} file - The file name to log to.
59
- * @param {string} level - The log level (e.g. info, error, warn, debug).
60
- * @param {string} message - The log message.
61
- */
62
- async _log(file, level, message) {
63
- const redisClient = getRedisClient();
64
- if (redisClient) {
65
- try {
66
- await redisClient.lPush(`bluebird:logs:${level}`, message);
67
- return;
68
- } catch (err) {
69
- console.error(
70
- `[LOGGER ERROR] Failed to write to Redis logs (${level}):`,
71
- err.message,
72
- );
73
- }
74
- }
75
-
76
- const logFile = path.join(this.nowFolder(), file);
77
- fs.appendFile(logFile, `${message}\n`, (err) => {
78
- if (err) console.error("Logger write error:", err.message);
79
- });
80
- }
81
-
82
- /**
83
- * Appends an informational message.
84
- * @param {string} message - The message to log.
85
- */
86
- info(message) {
87
- this._log("info.log", "info", message);
88
- }
89
-
90
- /**
91
- * Appends an error message.
92
- * @param {string} message - The error message to log.
93
- */
94
- error(message) {
95
- this._log("error.log", "error", message);
96
- }
97
-
98
- /**
99
- * Appends a warning message.
100
- * @param {string} message - The warning message to log.
101
- */
102
- warning(message) {
103
- this._log("warn.log", "warn", message);
104
- }
105
-
106
- /**
107
- * Alias for warning method.
108
- * @param {string} message - The warning message to log.
109
- */
110
- warn(message) {
111
- this.warning(message);
112
- }
113
-
114
- /**
115
- * Appends a debug message.
116
- * @param {string} message - The debug message to log.
117
- */
118
- debug(message) {
119
- this._log("debug.log", "debug", message);
120
- }
121
- }
122
-
123
- export { Logger };
124
- export default Logger;
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import Config from "./config.js";
4
+ import { getRedisClient } from "./cache.js";
5
+
6
+ /**
7
+ * Logger class for managing application logs by creating dated folders and log files.
8
+ */
9
+ class Logger {
10
+ /**
11
+ * Initializes the Logger instance and ensures the logs directory exists.
12
+ */
13
+ constructor() {
14
+ this.folder = path.join(Config.userDataDir(), "logs");
15
+ this._currentDay = null;
16
+ this._currentDayFolder = null;
17
+ }
18
+
19
+ /**
20
+ * Ensures and returns the path to the log folder for the current day.
21
+ * Caches the folder path for the current day to avoid repeated fs checks.
22
+ * @returns {string} The absolute path to the current day's log folder.
23
+ */
24
+ nowFolder() {
25
+ const today = this.now();
26
+
27
+ if (this._currentDay === today && this._currentDayFolder && fs.existsSync(this._currentDayFolder)) {
28
+ return this._currentDayFolder;
29
+ }
30
+
31
+ if (!fs.existsSync(this.folder)) {
32
+ try {
33
+ fs.mkdirSync(this.folder, { recursive: true });
34
+ } catch {}
35
+ }
36
+
37
+ const folder = path.join(this.folder, today);
38
+
39
+ if (!fs.existsSync(folder)) {
40
+ try {
41
+ fs.mkdirSync(folder, { recursive: true });
42
+ } catch {}
43
+ }
44
+
45
+ this._currentDay = today;
46
+ this._currentDayFolder = folder;
47
+ return folder;
48
+ }
49
+
50
+ /**
51
+ * Gets the current date formatted as YYYY-MM-DD.
52
+ * @returns {string} The formatted date string.
53
+ */
54
+ now() {
55
+ return new Date().toISOString().split("T")[0];
56
+ }
57
+
58
+ /**
59
+ * Logs a message to the specified log file or Redis list.
60
+ * @private
61
+ * @param {string} file - The file name to log to.
62
+ * @param {string} level - The log level (e.g. info, error, warn, debug).
63
+ * @param {string} message - The log message.
64
+ */
65
+ async _log(file, level, message) {
66
+ const redisClient = getRedisClient();
67
+ if (redisClient) {
68
+ try {
69
+ await redisClient.lPush(`bluebird:logs:${level}`, message);
70
+ return;
71
+ } catch (err) {
72
+ console.error(
73
+ `[LOGGER ERROR] Failed to write to Redis logs (${level}):`,
74
+ err.message,
75
+ );
76
+ }
77
+ }
78
+
79
+ const logFile = path.join(this.nowFolder(), file);
80
+ fs.appendFile(logFile, `${message}\n`, (err) => {
81
+ if (err) console.error("Logger write error:", err.message);
82
+ });
83
+ }
84
+
85
+ /**
86
+ * Appends an informational message.
87
+ * @param {string} message - The message to log.
88
+ */
89
+ info(message) {
90
+ this._log("info.log", "info", message);
91
+ }
92
+
93
+ /**
94
+ * Appends an error message.
95
+ * @param {string} message - The error message to log.
96
+ */
97
+ error(message) {
98
+ this._log("error.log", "error", message);
99
+ }
100
+
101
+ /**
102
+ * Appends a warning message.
103
+ * @param {string} message - The warning message to log.
104
+ */
105
+ warning(message) {
106
+ this._log("warn.log", "warn", message);
107
+ }
108
+
109
+ /**
110
+ * Alias for warning method.
111
+ * @param {string} message - The warning message to log.
112
+ */
113
+ warn(message) {
114
+ this.warning(message);
115
+ }
116
+
117
+ /**
118
+ * Appends a debug message.
119
+ * @param {string} message - The debug message to log.
120
+ */
121
+ debug(message) {
122
+ this._log("debug.log", "debug", message);
123
+ }
124
+ }
125
+
126
+ export { Logger };
127
+ export default Logger;
@@ -1,3 +1,3 @@
1
- import { Middleware, CommonMiddleware } from "./index.js";
2
- export default Middleware;
3
- export { Middleware, CommonMiddleware };
1
+ import { Middleware, CommonMiddleware } from "./index.js";
2
+ export default Middleware;
3
+ export { Middleware, CommonMiddleware };
@@ -1,28 +1,28 @@
1
- import Auth from "./auth.js";
2
-
3
- /**
4
- * Common middlewares for the Blue Bird framework.
5
- */
6
- const Middleware = {
7
- /**
8
- * Authentication protection middleware.
9
- * @type {Function}
10
- */
11
- auth: Auth.protect(),
12
-
13
- /**
14
- * Web authentication protection middleware (redirects to home if fails).
15
- * @type {Function}
16
- */
17
- webAuth: Auth.protect({ redirect: "/" }),
18
-
19
- /**
20
- * Logging middleware (can be extended).
21
- */
22
- logger: (req, res, next) => {
23
- next();
24
- }
25
- };
26
-
27
- export { Middleware };
28
- export default Middleware;
1
+ import Auth from "./auth.js";
2
+
3
+ /**
4
+ * Common middlewares for the Blue Bird framework.
5
+ */
6
+ const Middleware = {
7
+ /**
8
+ * Authentication protection middleware.
9
+ * @type {Function}
10
+ */
11
+ auth: Auth.protect(),
12
+
13
+ /**
14
+ * Web authentication protection middleware (redirects to home if fails).
15
+ * @type {Function}
16
+ */
17
+ webAuth: Auth.protect({ redirect: "/" }),
18
+
19
+ /**
20
+ * Logging middleware (can be extended).
21
+ */
22
+ logger: (req, res, next) => {
23
+ next();
24
+ }
25
+ };
26
+
27
+ export { Middleware };
28
+ export default Middleware;
package/core/model.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import {
2
- Model,
3
- ModelSchemaColumn,
4
- ModelFindOptions,
5
- ModelAllOptions,
6
- ModelPaginateOptions,
7
- ModelDeleteOptions,
8
- PaginatedResult,
9
- } from "./index.js";
10
- export default Model;
11
- export {
12
- Model,
13
- ModelSchemaColumn,
14
- ModelFindOptions,
15
- ModelAllOptions,
16
- ModelPaginateOptions,
17
- ModelDeleteOptions,
18
- PaginatedResult,
19
- };
1
+ import {
2
+ Model,
3
+ ModelSchemaColumn,
4
+ ModelFindOptions,
5
+ ModelAllOptions,
6
+ ModelPaginateOptions,
7
+ ModelDeleteOptions,
8
+ PaginatedResult,
9
+ } from "./index.js";
10
+ export default Model;
11
+ export {
12
+ Model,
13
+ ModelSchemaColumn,
14
+ ModelFindOptions,
15
+ ModelAllOptions,
16
+ ModelPaginateOptions,
17
+ ModelDeleteOptions,
18
+ PaginatedResult,
19
+ };