@seip/blue-bird 0.7.6 → 0.8.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.
Files changed (41) hide show
  1. package/.env_example +34 -34
  2. package/AGENTS.md +174 -249
  3. package/LICENSE +21 -21
  4. package/README.md +312 -367
  5. package/{index.js → backend/index.js} +22 -30
  6. package/backend/routes/api.js +57 -57
  7. package/core/app.js +338 -402
  8. package/core/auth.js +262 -256
  9. package/core/cache.js +174 -174
  10. package/core/cli/docker.js +488 -457
  11. package/core/cli/init.js +332 -336
  12. package/core/cli/route.js +42 -42
  13. package/core/config.js +52 -52
  14. package/core/database.js +263 -263
  15. package/core/debug.js +248 -248
  16. package/core/logger.js +115 -115
  17. package/core/middleware.js +27 -27
  18. package/core/router.js +144 -144
  19. package/core/swagger.js +40 -40
  20. package/core/upload.js +77 -77
  21. package/core/validate.js +380 -380
  22. package/docker/Dockerfile +16 -16
  23. package/docker/docker-compose.dev.yml +6 -0
  24. package/docker/docker-compose.mysql.yml +92 -92
  25. package/docker/docker-compose.none.yml +68 -68
  26. package/docker/docker-compose.postgres.yml +93 -93
  27. package/docker/nginx.conf +98 -106
  28. package/docker-compose.yml +92 -92
  29. package/frontend/about.html +98 -0
  30. package/frontend/css/app.css +0 -0
  31. package/frontend/favicon.ico +0 -0
  32. package/frontend/index.html +141 -0
  33. package/frontend/js/bundle.js +8 -0
  34. package/package.json +64 -71
  35. package/frontend/astro.config.mjs +0 -35
  36. package/frontend/public/css/app.css +0 -319
  37. package/frontend/public/favicon.ico +0 -0
  38. package/frontend/src/http/api.js +0 -29
  39. package/frontend/src/layouts/Layout.astro +0 -20
  40. package/frontend/src/pages/about.astro +0 -54
  41. package/frontend/src/pages/index.astro +0 -110
package/core/upload.js CHANGED
@@ -1,77 +1,77 @@
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
- const appUrl = props.appUrl ?? `${props.host}:${props.port}`;
73
- return `${appUrl}/${folder}/${filename}`;
74
- }
75
- }
76
-
77
- 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
+ const appUrl = props.appUrl ?? `${props.host}:${props.port}`;
73
+ return `${appUrl}/${folder}/${filename}`;
74
+ }
75
+ }
76
+
77
+ export default Upload;