@seip/blue-bird 0.4.4 → 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 (53) hide show
  1. package/.env_example +26 -25
  2. package/AGENTS.md +199 -199
  3. package/LICENSE +21 -0
  4. package/README.md +79 -79
  5. package/backend/index.js +13 -13
  6. package/backend/routes/api.js +31 -31
  7. package/backend/routes/frontend.js +41 -41
  8. package/backend/routes/seo.js +39 -39
  9. package/core/app.js +328 -325
  10. package/core/auth.js +114 -83
  11. package/core/cache.js +44 -44
  12. package/core/cli/component.js +42 -42
  13. package/core/cli/init.js +119 -118
  14. package/core/cli/react.js +435 -435
  15. package/core/cli/route.js +42 -42
  16. package/core/cli/scaffolding-auth.js +1037 -0
  17. package/core/config.js +48 -47
  18. package/core/debug.js +248 -248
  19. package/core/logger.js +100 -100
  20. package/core/middleware.js +27 -27
  21. package/core/router.js +333 -333
  22. package/core/seo.js +95 -100
  23. package/core/swagger.js +40 -25
  24. package/core/template.js +472 -462
  25. package/core/upload.js +76 -76
  26. package/core/validate.js +380 -380
  27. package/frontend/index.html +26 -26
  28. package/frontend/landing.html +69 -69
  29. package/frontend/resources/css/tailwind.css +17 -17
  30. package/frontend/resources/js/App.jsx +70 -70
  31. package/frontend/resources/js/Main.jsx +18 -18
  32. package/frontend/resources/js/blue-bird/components/Button.jsx +67 -67
  33. package/frontend/resources/js/blue-bird/components/Card.jsx +18 -18
  34. package/frontend/resources/js/blue-bird/components/DataTable.jsx +126 -126
  35. package/frontend/resources/js/blue-bird/components/Input.jsx +21 -21
  36. package/frontend/resources/js/blue-bird/components/Label.jsx +12 -12
  37. package/frontend/resources/js/blue-bird/components/LanguageButton.jsx +23 -23
  38. package/frontend/resources/js/blue-bird/components/Link.jsx +15 -15
  39. package/frontend/resources/js/blue-bird/components/Modal.jsx +27 -27
  40. package/frontend/resources/js/blue-bird/components/Skeleton.jsx +44 -44
  41. package/frontend/resources/js/blue-bird/components/Translate.jsx +12 -12
  42. package/frontend/resources/js/blue-bird/components/Typography.jsx +69 -69
  43. package/frontend/resources/js/blue-bird/contexts/LanguageContext.jsx +41 -41
  44. package/frontend/resources/js/blue-bird/contexts/SPAContext.jsx +239 -237
  45. package/frontend/resources/js/blue-bird/contexts/SnackbarContext.jsx +38 -38
  46. package/frontend/resources/js/blue-bird/contexts/ThemeContext.jsx +49 -49
  47. package/frontend/resources/js/blue-bird/locales/en.json +47 -47
  48. package/frontend/resources/js/blue-bird/locales/es.json +47 -47
  49. package/frontend/resources/js/components/Header.jsx +55 -55
  50. package/frontend/resources/js/pages/About.jsx +31 -31
  51. package/frontend/resources/js/pages/Home.jsx +82 -82
  52. package/package.json +57 -57
  53. package/vite.config.js +22 -22
package/core/upload.js CHANGED
@@ -1,76 +1,76 @@
1
- import multer from "multer";
2
- import path from "node:path";
3
- import fs from "node:fs";
4
- import Config from "./config.js";
5
-
6
- const __dirname = Config.dirname();
7
- const props = Config.props();
8
-
9
- /**
10
- * Upload helper to manage file uploads using multer.
11
- */
12
- class Upload {
13
- /**
14
- * Configures storage for uploaded files.
15
- * @param {string} folder - The destination folder within the static path.
16
- * @returns {import('multer').StorageEngine}
17
- * @example
18
- * const storage = Upload.storage("uploads");
19
- */
20
- static storage(folder = "uploads") {
21
- const dest = path.join(__dirname, props.static.path, folder);
22
-
23
- if (!fs.existsSync(dest)) {
24
- fs.mkdirSync(dest, { recursive: true });
25
- }
26
-
27
- return multer.diskStorage({
28
- destination: (req, file, cb) => {
29
- cb(null, dest);
30
- },
31
- filename: (req, file, cb) => {
32
- const uniqueSuffix = Date.now() + "-" + Math.round(Math.random() * 1e9);
33
- cb(null, uniqueSuffix + path.extname(file.originalname));
34
- }
35
- });
36
- }
37
-
38
- /**
39
- * Returns a multer instance for single or multiple file uploads.
40
- * @param {Object} options - Multer options.
41
- * @param {string} [options.folder='uploads'] - Destination folder.
42
- * @param {number} [options.fileSize=5000000] - Max file size in bytes (default 5MB).
43
- * @param {Array<string>} [options.allowedTypes=[]] - Allowed mime types (e.g. ['image/png', 'image/jpeg']).
44
- * @returns {import('multer').Multer}
45
- * @example
46
- * const upload = Upload.disk({ folder: "uploads", fileSize: 5000000, allowedTypes: ["image/png", "image/jpeg"] });
47
- */
48
- static disk(options = {}) {
49
- const { folder = "uploads", fileSize = 5000000, allowedTypes = [] } = options;
50
-
51
- return multer({
52
- storage: this.storage(folder),
53
- limits: { fileSize },
54
- fileFilter: (req, file, cb) => {
55
- if (allowedTypes.length > 0 && !allowedTypes.includes(file.mimetype)) {
56
- return cb(new Error("File type not allowed"), false);
57
- }
58
- cb(null, true);
59
- }
60
- });
61
- }
62
-
63
- /**
64
- * Helper to get the public URL of an uploaded file.
65
- * @param {string} filename - The name of the file.
66
- * @param {string} [folder='uploads'] - The folder where the file is stored.
67
- * @returns {string} The full public URL.
68
- * @example
69
- * const url = Upload.url("file.jpg", "uploads");
70
- */
71
- static url(filename, folder = "uploads") {
72
- return `${props.host}:${props.port}/${folder}/${filename}`;
73
- }
74
- }
75
-
76
- export default Upload;
1
+ import multer from "multer";
2
+ import path from "node:path";
3
+ import fs from "node:fs";
4
+ import Config from "./config.js";
5
+
6
+ const __dirname = Config.dirname();
7
+ const props = Config.props();
8
+
9
+ /**
10
+ * Upload helper to manage file uploads using multer.
11
+ */
12
+ class Upload {
13
+ /**
14
+ * Configures storage for uploaded files.
15
+ * @param {string} folder - The destination folder within the static path.
16
+ * @returns {import('multer').StorageEngine}
17
+ * @example
18
+ * const storage = Upload.storage("uploads");
19
+ */
20
+ static storage(folder = "uploads") {
21
+ const dest = path.join(__dirname, props.static.path, folder);
22
+
23
+ if (!fs.existsSync(dest)) {
24
+ fs.mkdirSync(dest, { recursive: true });
25
+ }
26
+
27
+ return multer.diskStorage({
28
+ destination: (req, file, cb) => {
29
+ cb(null, dest);
30
+ },
31
+ filename: (req, file, cb) => {
32
+ const uniqueSuffix = Date.now() + "-" + Math.round(Math.random() * 1e9);
33
+ cb(null, uniqueSuffix + path.extname(file.originalname));
34
+ }
35
+ });
36
+ }
37
+
38
+ /**
39
+ * Returns a multer instance for single or multiple file uploads.
40
+ * @param {Object} options - Multer options.
41
+ * @param {string} [options.folder='uploads'] - Destination folder.
42
+ * @param {number} [options.fileSize=5000000] - Max file size in bytes (default 5MB).
43
+ * @param {Array<string>} [options.allowedTypes=[]] - Allowed mime types (e.g. ['image/png', 'image/jpeg']).
44
+ * @returns {import('multer').Multer}
45
+ * @example
46
+ * const upload = Upload.disk({ folder: "uploads", fileSize: 5000000, allowedTypes: ["image/png", "image/jpeg"] });
47
+ */
48
+ static disk(options = {}) {
49
+ const { folder = "uploads", fileSize = 5000000, allowedTypes = [] } = options;
50
+
51
+ return multer({
52
+ storage: this.storage(folder),
53
+ limits: { fileSize },
54
+ fileFilter: (req, file, cb) => {
55
+ if (allowedTypes.length > 0 && !allowedTypes.includes(file.mimetype)) {
56
+ return cb(new Error("File type not allowed"), false);
57
+ }
58
+ cb(null, true);
59
+ }
60
+ });
61
+ }
62
+
63
+ /**
64
+ * Helper to get the public URL of an uploaded file.
65
+ * @param {string} filename - The name of the file.
66
+ * @param {string} [folder='uploads'] - The folder where the file is stored.
67
+ * @returns {string} The full public URL.
68
+ * @example
69
+ * const url = Upload.url("file.jpg", "uploads");
70
+ */
71
+ static url(filename, folder = "uploads") {
72
+ return `${props.host}:${props.port}/${folder}/${filename}`;
73
+ }
74
+ }
75
+
76
+ export default Upload;