@seip/blue-bird 0.4.5 → 0.4.6

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 (51) hide show
  1. package/.env_example +26 -25
  2. package/AGENTS.md +199 -199
  3. package/README.md +79 -79
  4. package/backend/index.js +13 -13
  5. package/backend/routes/frontend.js +41 -41
  6. package/backend/routes/seo.js +39 -39
  7. package/core/app.js +328 -325
  8. package/core/auth.js +114 -114
  9. package/core/cache.js +44 -44
  10. package/core/cli/component.js +42 -42
  11. package/core/cli/init.js +119 -118
  12. package/core/cli/react.js +435 -435
  13. package/core/cli/route.js +42 -42
  14. package/core/config.js +48 -47
  15. package/core/debug.js +248 -248
  16. package/core/logger.js +100 -100
  17. package/core/middleware.js +27 -27
  18. package/core/router.js +333 -333
  19. package/core/seo.js +95 -100
  20. package/core/template.js +472 -462
  21. package/core/upload.js +76 -76
  22. package/core/validate.js +380 -380
  23. package/frontend/index.html +26 -26
  24. package/frontend/landing.html +69 -69
  25. package/frontend/resources/css/tailwind.css +17 -17
  26. package/frontend/resources/js/App.jsx +70 -70
  27. package/frontend/resources/js/Main.jsx +18 -18
  28. package/frontend/resources/js/blue-bird/components/Button.jsx +67 -67
  29. package/frontend/resources/js/blue-bird/components/Card.jsx +18 -18
  30. package/frontend/resources/js/blue-bird/components/DataTable.jsx +126 -126
  31. package/frontend/resources/js/blue-bird/components/Input.jsx +21 -21
  32. package/frontend/resources/js/blue-bird/components/Label.jsx +12 -12
  33. package/frontend/resources/js/blue-bird/components/LanguageButton.jsx +23 -23
  34. package/frontend/resources/js/blue-bird/components/Link.jsx +15 -15
  35. package/frontend/resources/js/blue-bird/components/Modal.jsx +27 -27
  36. package/frontend/resources/js/blue-bird/components/Skeleton.jsx +44 -44
  37. package/frontend/resources/js/blue-bird/components/Translate.jsx +12 -12
  38. package/frontend/resources/js/blue-bird/components/Typography.jsx +69 -69
  39. package/frontend/resources/js/blue-bird/contexts/LanguageContext.jsx +41 -41
  40. package/frontend/resources/js/blue-bird/contexts/SPAContext.jsx +239 -237
  41. package/frontend/resources/js/blue-bird/contexts/SnackbarContext.jsx +38 -38
  42. package/frontend/resources/js/blue-bird/contexts/ThemeContext.jsx +49 -49
  43. package/frontend/resources/js/blue-bird/locales/en.json +47 -47
  44. package/frontend/resources/js/blue-bird/locales/es.json +47 -47
  45. package/frontend/resources/js/components/Header.jsx +55 -55
  46. package/frontend/resources/js/pages/About.jsx +31 -31
  47. package/frontend/resources/js/pages/Home.jsx +82 -82
  48. package/package.json +57 -57
  49. package/vite.config.js +22 -22
  50. package/frontend/public/robots.txt +0 -0
  51. package/frontend/public/sitemap.xml +0 -0
package/core/app.js CHANGED
@@ -1,325 +1,328 @@
1
- import express from "express";
2
- import cors from "cors";
3
- import path from "path";
4
- import chalk from "chalk";
5
- import helmet from "helmet";
6
- import cookieParser from "cookie-parser";
7
- import rateLimit from "express-rate-limit";
8
- import compression from "compression";
9
- import Config from "./config.js";
10
- import Logger from "./logger.js";
11
- import Debug from "./debug.js";
12
-
13
- const __dirname = Config.dirname();
14
- const props = Config.props();
15
-
16
- /**
17
- * Main Application class to manage Express server, routes, and middlewares.
18
- */
19
- class App {
20
- /**
21
- * Initializes the App instance with the provided options.
22
- * @param {Object} [options] - Configuration options for the application.
23
- * @param {Array<{path: string, router: import('express').Router}>} [options.routes=[]] - Array of route objects containing path and router components.
24
- * @param {Object} [options.cors={}] - CORS configuration options.
25
- * @param {Array<Function>} [options.middlewares=[]] - Array of middleware functions to be applied.
26
- * @param {number|string} [options.port=3000] - Server port.
27
- * @param {string} [options.host="http://localhost"] - Server host URL.
28
- * @param {boolean} [options.logger=true] - Whether to enable the request logger.
29
- * @param {boolean} [options.notFound=true] - Whether to enable the default 404 handler.
30
- * @param {boolean} [options.json=true] - Whether to enable JSON body parsing.
31
- * @param {boolean} [options.urlencoded=true] - Whether to enable URL-encoded body parsing.
32
- * @param {Object} [options.static={path: null, options: {}}] - Static file configuration.
33
- * @param {boolean} [options.cookieParser=true] - Whether to enable cookie parsing.
34
- * @param {boolean|Object} [options.rateLimit=false] - Enable global rate limiting.
35
- * @param {boolean|Object} [options.swagger=false] - Enable swagger
36
- * @param {boolean} [options.compression=true] - Enable Gzip compression.
37
- * @example
38
- * const app = new App({
39
- * routes: [],
40
- * cors: {}, // { origin: "https://domain:port" }
41
- * middlewares: [],
42
- * port: 3000,
43
- * host: "http://localhost",
44
- * logger: true,
45
- * notFound: true,
46
- * json: true,
47
- * urlencoded: true,
48
- * static: {
49
- * path: "public",
50
- * options: {}
51
- * },
52
- * cookieParser: true,
53
- * rateLimit: {
54
- * windowMs: 10 * 60 * 1000,
55
- * max: 50
56
- * },
57
- * swagger:{
58
- * info: {
59
- * title: "Blue Bird API",
60
- * version: "1.0.0",
61
- * description: "Blue Bird Framework API Documentation"
62
- * },
63
- * url : "http://localhost:8000"
64
- * },
65
- * compression: true
66
- * });
67
- */
68
- constructor(options = {}) {
69
- this.app = express();
70
- this.routes = options.routes || [];
71
- this.cors = options.cors || {};
72
- this.middlewares = options.middlewares || [];
73
- this.port = options.port || props.port;
74
- this.host = options.host || props.host;
75
- this.logger = options.logger ?? false;
76
- this.notFound = options.notFound ?? true;
77
- this.json = options.json ?? true;
78
- this.urlencoded = options.urlencoded ?? true;
79
- this.static = options.static || props.static;
80
- this.cookieParser = options.cookieParser ?? true;
81
- this.rateLimit = options.rateLimit ?? false;
82
- this.swagger = options.swagger ?? false;
83
- this.compression = options.compression ?? true;
84
- this._ready = this._dispatch();
85
- }
86
-
87
- /**
88
- * Registers a custom middleware or module in the Express application.
89
- * @param {Function|import('express').Router} record - The middleware function or Express router to register.
90
- * @example
91
- * app.use((req, res, next) => {
92
- * console.log("Middleware");
93
- * next();
94
- * });
95
- */
96
- use(record) {
97
- this.app.use(record);
98
- }
99
- /**
100
- * Sets a configuration value in the Express application.
101
- * @param {string} key - The configuration key.
102
- * @param {*} value - The value to set for the configuration key.
103
- * @example
104
- * app.set("port", 3000);
105
- */
106
- set(key, value) {
107
- this.app.set(key, value);
108
- }
109
-
110
- /**
111
- * Bootstraps the application by configuring global middlewares and routes.
112
- * Sets up JSON parsing, URL encoding, CORS, and custom middlewares.
113
- * @private
114
- */
115
- async _dispatch() {
116
- if (this.compression) this.app.use(compression());
117
- if (this.json) this.app.use(express.json());
118
- if (this.urlencoded) this.app.use(express.urlencoded({ extended: true }));
119
- if (this.cookieParser) this.app.use(cookieParser());
120
- if (this.static.path)
121
- this.app.use(
122
- express.static(
123
- path.join(__dirname, this.static.path),
124
- this.static.options,
125
- ),
126
- );
127
-
128
- this.app.use(cors(this.cors));
129
- if (this.rateLimit) {
130
- if (!this.app.get("trust proxy")) {
131
- this.app.set("trust proxy", 1);
132
- }
133
- const defaultRateLimit = {
134
- windowMs: 15 * 60 * 1000,
135
- max: 500,
136
- standardHeaders: true,
137
- legacyHeaders: false,
138
- message: {
139
- success: false,
140
- message: "Too many requests, please try again later.",
141
- },
142
- };
143
- const optionsRateLimiter = {
144
- ...defaultRateLimit,
145
- ...(typeof this.rateLimit === "object" ? this.rateLimit : {}),
146
- };
147
-
148
- if (props.debug) {
149
- optionsRateLimiter.skip = (req) => req.path.startsWith("/debug");
150
- }
151
-
152
- const limiter = rateLimit(optionsRateLimiter);
153
-
154
- this.app.use(limiter);
155
- }
156
-
157
- this.middlewares.forEach((middleware) => {
158
- this.app.use(middleware);
159
- });
160
-
161
- if (this.logger) this._middlewareLogger();
162
-
163
- this.app.use((req, res, next) => {
164
- res.setHeader("X-Powered-By", "Blue Bird");
165
- next();
166
- });
167
-
168
- if (props.debug) {
169
- Debug.middlewareMetrics(this.app);
170
- }
171
-
172
- if (this.swagger) {
173
- const { default: Swagger } = await import("./swagger.js");
174
- const defaultSwaggerOptions = {
175
- info: {
176
- title: "Blue Bird API",
177
- version: "1.0.0",
178
- description: "Blue Bird Framework API Documentation",
179
- },
180
- url: `${this.host}:${this.port}`,
181
- route: "/docs",
182
- };
183
-
184
- const swaggerOptions = {
185
- ...defaultSwaggerOptions,
186
- ...(typeof this.swagger === "object" ? this.swagger : {}),
187
- };
188
-
189
- Swagger.init(this.app, swaggerOptions);
190
- }
191
-
192
- this._dispatchRoutes();
193
-
194
- if (this.notFound) this._notFoundDefault();
195
-
196
- this._errorHandler();
197
- }
198
-
199
- /**
200
- * Middleware that logs incoming HTTP requests to the console and to a log file.
201
- * @private
202
- */
203
- _middlewareLogger() {
204
- const logger = new Logger();
205
- this.app.use((req, res, next) => {
206
- const method = req.method;
207
- const url = req.url.replace(
208
- /(password|token|authorization)=([^&]+)/gi,
209
- "$1=***",
210
- );
211
- const params =
212
- Object.keys(req.params).length > 0
213
- ? ` ${JSON.stringify(req.params)}`
214
- : "";
215
- const ip = req.ip;
216
- const now = new Date().toISOString();
217
- const time = `${now.split("T")[0]} ${now.split("T")[1].split(".")[0]}`;
218
- let message = ` ${time} -${ip} -[${method}] ${url} ${params}`;
219
-
220
- logger.info(message);
221
- if (props.debug) {
222
- message = `${chalk.bold.green(time)} - ${chalk.bold.cyan(ip)} -[${chalk.bold.red(method)}] ${chalk.bold.blue(url)} ${chalk.bold.yellow(params)}`;
223
- console.log(message);
224
- }
225
- next();
226
- });
227
- }
228
-
229
- /**
230
- * Global error handler for the application.
231
- * Catches all errors and responds with a standardized JSON structure.
232
- * @private
233
- */
234
- _errorHandler() {
235
- this.app.use((err, req, res, next) => {
236
- const logger = new Logger();
237
- const status = err.status || 500;
238
- const message = err.message || "Internal Server Error";
239
-
240
- logger.error(`[${status}] ${message} - ${err.stack}`);
241
-
242
- if (props.debug) {
243
- return res.status(status).json({
244
- success: false,
245
- error: true,
246
- message: message,
247
- stack: err.stack,
248
- });
249
- }
250
-
251
- return res.status(status).json({
252
- success: false,
253
- error: true,
254
- message: status === 500 ? "Internal Server Error" : message,
255
- });
256
- });
257
- }
258
-
259
- /**
260
- * Iterates through the stored routes and attaches them to the Express application instance.
261
- * @private
262
- */
263
- _dispatchRoutes() {
264
- if (props.debug) {
265
- const debug = new Debug();
266
- const debugRouter = debug.getRouter();
267
- this.app.use(debugRouter.path, debugRouter.router);
268
- }
269
- this.routes.forEach((route) => {
270
- this.app.use(route.path, route.router);
271
- });
272
- }
273
- /**
274
- * Default 404 handler for unmatched routes.
275
- * Returns a JSON response with a "Not Found" message.
276
- * @private
277
- */
278
- _notFoundDefault() {
279
- this.app.use((req, res) => {
280
- return res.status(404).json({ message: "Not Found" });
281
- });
282
- }
283
- /**
284
- * Starts the HTTP server and begins listening for incoming connections.
285
- * Waits for dispatch to complete before starting.
286
- */
287
- run() {
288
- this._ready
289
- .then(() => {
290
- this.app.listen(this.port, () => {
291
- console.log(
292
- chalk.bold.blue("Blue Bird Server Online\n") +
293
- chalk.bold.cyan("Host: ") +
294
- chalk.green(`${this.host}:${this.port}`) +
295
- "\n" +
296
- chalk.gray("────────────────────────────────"),
297
- );
298
- });
299
- })
300
- .catch((err) => {
301
- console.error(
302
- chalk.bold.red("Failed to start Blue Bird:"),
303
- err.message,
304
- );
305
- process.exit(1);
306
- });
307
- }
308
-
309
- /**
310
- * Returns a pre-configured Helmet middleware for use on specific routers.
311
- * @param {Object} [options={}] - Helmet options to override defaults.
312
- * @returns {Function} Helmet middleware function.
313
- * @example
314
- * const router = new Router("/web");
315
- * router.use(App.helmet({ contentSecurityPolicy: false }));
316
- */
317
- static helmet(options = {}) {
318
- const defaultOptions = {
319
- contentSecurityPolicy: props.debug ? false : undefined,
320
- };
321
- return helmet({ ...defaultOptions, ...options });
322
- }
323
- }
324
-
325
- export default App;
1
+ import express from "express";
2
+ import cors from "cors";
3
+ import path from "path";
4
+ import chalk from "chalk";
5
+ import helmet from "helmet";
6
+ import cookieParser from "cookie-parser";
7
+ import rateLimit from "express-rate-limit";
8
+ import compression from "compression";
9
+ import Config from "./config.js";
10
+ import Logger from "./logger.js";
11
+ import Debug from "./debug.js";
12
+
13
+ const __dirname = Config.dirname();
14
+ const props = Config.props();
15
+
16
+ /**
17
+ * Main Application class to manage Express server, routes, and middlewares.
18
+ */
19
+ class App {
20
+ /**
21
+ * Initializes the App instance with the provided options.
22
+ * @param {Object} [options] - Configuration options for the application.
23
+ * @param {Array<{path: string, router: import('express').Router}>} [options.routes=[]] - Array of route objects containing path and router components.
24
+ * @param {Object} [options.cors={}] - CORS configuration options.
25
+ * @param {Array<Function>} [options.middlewares=[]] - Array of middleware functions to be applied.
26
+ * @param {number|string} [options.port=3000] - Server port.
27
+ * @param {string} [options.host="http://localhost"] - Server host URL.
28
+ * @param {boolean} [options.logger=true] - Whether to enable the request logger.
29
+ * @param {boolean} [options.notFound=true] - Whether to enable the default 404 handler.
30
+ * @param {boolean} [options.json=true] - Whether to enable JSON body parsing.
31
+ * @param {boolean} [options.urlencoded=true] - Whether to enable URL-encoded body parsing.
32
+ * @param {Object} [options.static={path: null, options: {}}] - Static file configuration.
33
+ * @param {boolean} [options.cookieParser=true] - Whether to enable cookie parsing.
34
+ * @param {boolean|Object} [options.rateLimit=false] - Enable global rate limiting.
35
+ * @param {boolean|Object} [options.swagger=false] - Enable swagger
36
+ * @param {boolean} [options.compression=true] - Enable Gzip compression.
37
+ * @example
38
+ * const app = new App({
39
+ * routes: [],
40
+ * cors: {}, // { origin: "https://domain:port" }
41
+ * middlewares: [],
42
+ * port: 3000,
43
+ * host: "http://localhost",
44
+ * logger: true,
45
+ * notFound: true,
46
+ * json: true,
47
+ * urlencoded: true,
48
+ * static: {
49
+ * path: "public",
50
+ * options: {}
51
+ * },
52
+ * cookieParser: true,
53
+ * rateLimit: {
54
+ * windowMs: 10 * 60 * 1000,
55
+ * max: 50
56
+ * },
57
+ * swagger:{
58
+ * info: {
59
+ * title: "Blue Bird API",
60
+ * version: "1.0.0",
61
+ * description: "Blue Bird Framework API Documentation"
62
+ * },
63
+ * url : "http://localhost:8000"
64
+ * },
65
+ * compression: true
66
+ * });
67
+ */
68
+ constructor(options = {}) {
69
+ this.app = express();
70
+ this.routes = options.routes || [];
71
+ this.cors = options.cors || {};
72
+ this.middlewares = options.middlewares || [];
73
+ this.port = options.port || props.port;
74
+ this.host = options.host || props.host;
75
+ this.appUrl = options.appUrl || props.appUrl;
76
+ this.logger = options.logger ?? false;
77
+ this.notFound = options.notFound ?? true;
78
+ this.json = options.json ?? true;
79
+ this.urlencoded = options.urlencoded ?? true;
80
+ this.static = options.static || props.static;
81
+ this.cookieParser = options.cookieParser ?? true;
82
+ this.rateLimit = options.rateLimit ?? false;
83
+ this.swagger = options.swagger ?? false;
84
+ this.compression = options.compression ?? true;
85
+ this.loggerInstance = new Logger();
86
+ this._ready = this._dispatch();
87
+ }
88
+
89
+ /**
90
+ * Registers a custom middleware or module in the Express application.
91
+ * @param {Function|import('express').Router} record - The middleware function or Express router to register.
92
+ * @example
93
+ * app.use((req, res, next) => {
94
+ * console.log("Middleware");
95
+ * next();
96
+ * });
97
+ */
98
+ use(record) {
99
+ this.app.use(record);
100
+ }
101
+ /**
102
+ * Sets a configuration value in the Express application.
103
+ * @param {string} key - The configuration key.
104
+ * @param {*} value - The value to set for the configuration key.
105
+ * @example
106
+ * app.set("port", 3000);
107
+ */
108
+ set(key, value) {
109
+ this.app.set(key, value);
110
+ }
111
+
112
+ /**
113
+ * Bootstraps the application by configuring global middlewares and routes.
114
+ * Sets up JSON parsing, URL encoding, CORS, and custom middlewares.
115
+ * @private
116
+ */
117
+ async _dispatch() {
118
+ if (this.compression) this.app.use(compression());
119
+ if (this.json) this.app.use(express.json());
120
+ if (this.urlencoded) this.app.use(express.urlencoded({ extended: true }));
121
+ if (this.cookieParser) this.app.use(cookieParser());
122
+ if (this.static.path)
123
+ this.app.use(
124
+ express.static(
125
+ path.join(__dirname, this.static.path),
126
+ this.static.options,
127
+ ),
128
+ );
129
+
130
+ this.app.use(cors(this.cors));
131
+ if (this.rateLimit) {
132
+ if (!this.app.get("trust proxy")) {
133
+ this.app.set("trust proxy", 1);
134
+ }
135
+ const defaultRateLimit = {
136
+ windowMs: 15 * 60 * 1000,
137
+ max: 500,
138
+ standardHeaders: true,
139
+ legacyHeaders: false,
140
+ message: {
141
+ success: false,
142
+ message: "Too many requests, please try again later.",
143
+ },
144
+ };
145
+ const optionsRateLimiter = {
146
+ ...defaultRateLimit,
147
+ ...(typeof this.rateLimit === "object" ? this.rateLimit : {}),
148
+ };
149
+
150
+ if (props.debug) {
151
+ optionsRateLimiter.skip = (req) => req.path.startsWith("/debug");
152
+ }
153
+
154
+ const limiter = rateLimit(optionsRateLimiter);
155
+
156
+ this.app.use(limiter);
157
+ }
158
+
159
+ this.middlewares.forEach((middleware) => {
160
+ this.app.use(middleware);
161
+ });
162
+
163
+ if (this.logger) this._middlewareLogger();
164
+
165
+ this.app.use((req, res, next) => {
166
+ res.setHeader("X-Powered-By", "Blue Bird");
167
+ next();
168
+ });
169
+
170
+ if (props.debug) {
171
+ Debug.middlewareMetrics(this.app);
172
+ }
173
+
174
+ if (this.swagger) {
175
+ const { default: Swagger } = await import("./swagger.js");
176
+ const defaultSwaggerOptions = {
177
+ info: {
178
+ title: "Blue Bird API",
179
+ version: "1.0.0",
180
+ description: "Blue Bird Framework API Documentation",
181
+ },
182
+ url: this.appUrl ? this.appUrl : `${this.host}:${this.port}`,
183
+ route: "/docs",
184
+ };
185
+
186
+ const swaggerOptions = {
187
+ ...defaultSwaggerOptions,
188
+ ...(typeof this.swagger === "object" ? this.swagger : {}),
189
+ };
190
+
191
+ Swagger.init(this.app, swaggerOptions);
192
+ }
193
+
194
+ this._dispatchRoutes();
195
+
196
+ if (this.notFound) this._notFoundDefault();
197
+
198
+ this._errorHandler();
199
+ }
200
+
201
+ /**
202
+ * Middleware that logs incoming HTTP requests to the console and to a log file.
203
+ * @private
204
+ */
205
+ _middlewareLogger() {
206
+ this.app.use((req, res, next) => {
207
+ const method = req.method;
208
+ const url = req.url.replace(
209
+ /(password|token|authorization)=([^&]+)/gi,
210
+ "$1=***",
211
+ );
212
+ const params =
213
+ Object.keys(req.params).length > 0
214
+ ? ` ${JSON.stringify(req.params)}`
215
+ : "";
216
+ const ip = req.ip;
217
+ const now = new Date().toISOString();
218
+ const time = `${now.split("T")[0]} ${now.split("T")[1].split(".")[0]}`;
219
+ let message = ` ${time} -${ip} -[${method}] ${url} ${params}`;
220
+
221
+ this.loggerInstance.info(message);
222
+ if (props.debug) {
223
+ message = `${chalk.bold.green(time)} - ${chalk.bold.cyan(ip)} -[${chalk.bold.red(method)}] ${chalk.bold.blue(url)} ${chalk.bold.yellow(params)}`;
224
+ console.log(message);
225
+ }
226
+ next();
227
+ });
228
+ }
229
+
230
+ /**
231
+ * Global error handler for the application.
232
+ * Catches all errors and responds with a standardized JSON structure.
233
+ * @private
234
+ */
235
+ _errorHandler() {
236
+ this.app.use((err, req, res, next) => {
237
+ const status = err.status || 500;
238
+ const message = err.message || "Internal Server Error";
239
+
240
+ this.loggerInstance.error(`[${status}] ${message} - ${err.stack}`);
241
+
242
+ if (props.debug) {
243
+ return res.status(status).json({
244
+ success: false,
245
+ error: true,
246
+ message: message,
247
+ stack: err.stack,
248
+ });
249
+ }
250
+
251
+ return res.status(status).json({
252
+ success: false,
253
+ error: true,
254
+ message: status === 500 ? "Internal Server Error" : message,
255
+ });
256
+ });
257
+ }
258
+
259
+ /**
260
+ * Iterates through the stored routes and attaches them to the Express application instance.
261
+ * @private
262
+ */
263
+ _dispatchRoutes() {
264
+ if (props.debug) {
265
+ const debug = new Debug();
266
+ const debugRouter = debug.getRouter();
267
+ this.app.use(debugRouter.path, debugRouter.router);
268
+ }
269
+ this.routes.forEach((route) => {
270
+ this.app.use(route.path, route.router);
271
+ });
272
+ }
273
+ /**
274
+ * Default 404 handler for unmatched routes.
275
+ * Returns a JSON response with a "Not Found" message.
276
+ * @private
277
+ */
278
+ _notFoundDefault() {
279
+ this.app.use((req, res) => {
280
+ return res.status(404).json({ message: "Not Found" });
281
+ });
282
+ }
283
+ /**
284
+ * Starts the HTTP server and begins listening for incoming connections.
285
+ * Waits for dispatch to complete before starting.
286
+ */
287
+ run() {
288
+ this._ready
289
+ .then(() => {
290
+ this.app.listen(this.port, () => {
291
+ console.log(
292
+ chalk.bold.blue("Blue Bird Server Online\n") +
293
+ chalk.bold.cyan("App URL: ") +
294
+ chalk.green(`${this.appUrl}`) +
295
+ "\n" +
296
+ chalk.bold.cyan("Internal: ") +
297
+ chalk.green(`${this.host}:${this.port}`) +
298
+ "\n" +
299
+ chalk.gray("────────────────────────────────"),
300
+ );
301
+ });
302
+ })
303
+ .catch((err) => {
304
+ console.error(
305
+ chalk.bold.red("Failed to start Blue Bird:"),
306
+ err.message,
307
+ );
308
+ process.exit(1);
309
+ });
310
+ }
311
+
312
+ /**
313
+ * Returns a pre-configured Helmet middleware for use on specific routers.
314
+ * @param {Object} [options={}] - Helmet options to override defaults.
315
+ * @returns {Function} Helmet middleware function.
316
+ * @example
317
+ * const router = new Router("/web");
318
+ * router.use(App.helmet({ contentSecurityPolicy: false }));
319
+ */
320
+ static helmet(options = {}) {
321
+ const defaultOptions = {
322
+ contentSecurityPolicy: props.debug ? false : undefined,
323
+ };
324
+ return helmet({ ...defaultOptions, ...options });
325
+ }
326
+ }
327
+
328
+ export default App;