mbkbucket 3.3.1 → 3.4.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 (35) hide show
  1. package/README.md +17 -24
  2. package/index.js +2 -12
  3. package/lib/cli.js +191 -525
  4. package/lib/public/bucketadmin.js +1 -1
  5. package/lib/src/app.js +37 -50
  6. package/lib/src/cli/auth-helper.js +39 -112
  7. package/lib/src/config/index.js +68 -96
  8. package/lib/src/config/validation.js +14 -30
  9. package/lib/src/controllers/api.controller.js +85 -176
  10. package/lib/src/controllers/dashboard.controller.js +12 -23
  11. package/lib/src/controllers/info.controller.js +17 -20
  12. package/lib/src/controllers/view.controller.js +23 -70
  13. package/lib/src/middleware/async-handler.js +1 -16
  14. package/lib/src/middleware/bucket-resolver.js +7 -13
  15. package/lib/src/middleware/error-handler.js +40 -20
  16. package/lib/src/middleware/rate-limiter.js +2 -10
  17. package/lib/src/middleware/security.js +1 -17
  18. package/lib/src/routes/api.routes.js +21 -47
  19. package/lib/src/routes/index.js +2 -10
  20. package/lib/src/routes/info.routes.js +2 -3
  21. package/lib/src/routes/view.routes.js +3 -8
  22. package/lib/src/services/s3.service.js +157 -349
  23. package/lib/src/utils/errors.js +37 -59
  24. package/lib/src/utils/helpers.js +124 -70
  25. package/package.json +13 -5
  26. /package/{lib/views → views}/bucket.handlebars +0 -0
  27. /package/{lib/views → views}/bucketadmin_alerts.handlebars +0 -0
  28. /package/{lib/views → views}/bucketadmin_delete_modal.handlebars +0 -0
  29. /package/{lib/views → views}/bucketadmin_filelist_skeleton.handlebars +0 -0
  30. /package/{lib/views → views}/bucketadmin_newfolder_modal.handlebars +0 -0
  31. /package/{lib/views → views}/bucketadmin_preview_modal.handlebars +0 -0
  32. /package/{lib/views → views}/bucketadmin_upload_modal.handlebars +0 -0
  33. /package/{lib/views → views}/bucketadmincontent.handlebars +0 -0
  34. /package/{lib/views → views}/bucketportal.handlebars +0 -0
  35. /package/{lib/views → views}/mbkbucket_info.handlebars +0 -0
package/README.md CHANGED
@@ -37,14 +37,7 @@ npm install mbkbucket
37
37
  ### As a Library
38
38
 
39
39
  ```js
40
- import {
41
- uploadFile,
42
- downloadFile,
43
- listfiles,
44
- deleteFile,
45
- deleteFolder,
46
- getFileMetadata,
47
- generateSignedUrl,
40
+ import { uploadFile, downloadFile, listfiles, deleteFile, deleteFolder, getFileMetadata, generateSignedUrl,
48
41
  bucket, // Express router
49
42
  packageJson // Package metadata
50
43
  } from 'mbkbucket';
@@ -82,7 +75,7 @@ mbkbucket.listen(3004, () => {
82
75
  ```
83
76
 
84
77
  The Express app includes:
85
- - **`/mbkbucket`** — Admin dashboard (SuperAdmin only)
78
+ - **`/mbkbucket`** — Admin dashboard (superadmin only)
86
79
  - **`/mbkbucket/api/*`** — REST API for file operations
87
80
  - **`/mbkbucket/p_view/:key(*)`** — Public file view
88
81
  - **`/mbkbucket/info`** — Health & config info
@@ -225,23 +218,23 @@ All functions are exported from the package root. Full TypeScript declarations i
225
218
 
226
219
  | Route | Auth | Description |
227
220
  |---|---|---|
228
- | `GET /mbkbucket` | SuperAdmin | Admin dashboard |
221
+ | `GET /mbkbucket` | superadmin | Admin dashboard |
229
222
  | `GET /mbkbucket/info` | Any | Health check & config info |
230
223
  | `GET /mbkbucket/p_view/:key(*)` | Public | Public file viewer |
231
- | `POST /mbkbucket/api/list` | SuperAdmin | List files (JSON) |
232
- | `POST /mbkbucket/api/upload` | SuperAdmin | Upload file(s) |
233
- | `POST /mbkbucket/api/delete` | SuperAdmin | Delete file(s) |
234
- | `POST /mbkbucket/api/delete-folder` | SuperAdmin | Delete folder |
235
- | `POST /mbkbucket/api/create-folder` | SuperAdmin | Create folder marker |
236
- | `POST /mbkbucket/api/rename` | SuperAdmin | Rename/move a file |
237
- | `GET /mbkbucket/api/download/:key(*)` | SuperAdmin | Download a file |
238
- | `GET /mbkbucket/api/metadata/:key(*)` | SuperAdmin | Get file metadata |
239
- | `POST /mbkbucket/api/multipart/init` | SuperAdmin | Init multipart upload |
240
- | `POST /mbkbucket/api/multipart/part` | SuperAdmin | Upload multipart chunk |
241
- | `POST /mbkbucket/api/multipart/complete` | SuperAdmin | Complete multipart |
242
- | `POST /mbkbucket/api/multipart/abort` | SuperAdmin | Abort multipart |
243
- | `GET /mbkbucket/api/multipart/list` | SuperAdmin | List incomplete uploads |
244
- | `POST /mbkbucket/api/multipart/cleanup` | SuperAdmin | Clean up stale uploads |
224
+ | `POST /mbkbucket/api/list` | superadmin | List files (JSON) |
225
+ | `POST /mbkbucket/api/upload` | superadmin | Upload file(s) |
226
+ | `POST /mbkbucket/api/delete` | superadmin | Delete file(s) |
227
+ | `POST /mbkbucket/api/delete-folder` | superadmin | Delete folder |
228
+ | `POST /mbkbucket/api/create-folder` | superadmin | Create folder marker |
229
+ | `POST /mbkbucket/api/rename` | superadmin | Rename/move a file |
230
+ | `GET /mbkbucket/api/download/:key(*)` | superadmin | Download a file |
231
+ | `GET /mbkbucket/api/metadata/:key(*)` | superadmin | Get file metadata |
232
+ | `POST /mbkbucket/api/multipart/init` | superadmin | Init multipart upload |
233
+ | `POST /mbkbucket/api/multipart/part` | superadmin | Upload multipart chunk |
234
+ | `POST /mbkbucket/api/multipart/complete` | superadmin | Complete multipart |
235
+ | `POST /mbkbucket/api/multipart/abort` | superadmin | Abort multipart |
236
+ | `GET /mbkbucket/api/multipart/list` | superadmin | List incomplete uploads |
237
+ | `POST /mbkbucket/api/multipart/cleanup` | superadmin | Clean up stale uploads |
245
238
 
246
239
  ### Views
247
240
 
package/index.js CHANGED
@@ -2,33 +2,23 @@ import dotenv from "dotenv";
2
2
  import { createApp } from "./lib/src/app.js";
3
3
  import { checkVersion } from "./lib/src/config/index.js";
4
4
  import { runHealthCheck } from "./lib/src/services/s3.service.js";
5
- import { createLogger } from "./lib/src/utils/logger.js";
5
+ import { createLogger } from "#logger";
6
6
 
7
7
  dotenv.config();
8
8
 
9
9
  const debugServer = createLogger('server');
10
10
  const port = process.env.PORT || 3004;
11
- const isDevMode = process.env.NODE_ENV === "dev";
12
-
13
- // Create and start the Express application
14
11
  const server = createApp();
15
12
 
16
- if (isDevMode) {
17
-
18
- // Check for package updates and S3 connectivity on startup
13
+ if (process.env.NODE_ENV === "dev") {
19
14
  await checkVersion();
20
15
  await runHealthCheck();
21
-
22
16
  server.listen(port, () => {
23
17
  debugServer("Server running on http://localhost:%s", port);
24
18
  });
25
-
26
19
  }
27
20
 
28
- // Re-export the public API for consumers of this package (named exports only)
29
21
  export * from "./lib/src/services/s3.service.js";
30
22
  export * from "./lib/src/config/index.js";
31
23
  export { default as bucket } from "./lib/src/routes/index.js";
32
-
33
- // Default export: the Express application instance
34
24
  export default server;