mbkbucket 1.1.2 → 1.2.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.
package/index.js CHANGED
@@ -8,16 +8,22 @@ import compression from "compression";
8
8
  import rateLimit from 'express-rate-limit';
9
9
  import bucket from "./lib/bucket.js";
10
10
  import { checkVersion } from "./lib/config/index.js";
11
+ import { appVersion } from "./lib/config/index.js";
11
12
 
12
13
  dotenv.config();
13
14
 
14
15
  const __filename = fileURLToPath(import.meta.url);
15
16
  const __dirname = path.dirname(__filename);
17
+ const assetVersion = appVersion;
16
18
 
17
19
  const server = express();
18
20
  server.set('trust proxy', 1);
19
21
 
20
22
  server.use(compression());
23
+ server.use((req, res, next) => {
24
+ res.locals.assetVersion = assetVersion;
25
+ next();
26
+ });
21
27
 
22
28
  // Rate limiting: general limiter for typical browsing/API usage and a stricter
23
29
  // limiter for dashboard (admin) routes.
@@ -34,6 +40,9 @@ const generalLimiter = rateLimit({
34
40
  server.use(express.json());
35
41
  server.use(express.urlencoded({ extended: true }));
36
42
 
43
+ // Serve static assets from /public (CSS/JS/images)
44
+ server.use(express.static(path.join(__dirname, 'public'), { maxAge: '365d', etag: true }));
45
+
37
46
  // Configure Handlebars (single setup)
38
47
  server.engine("handlebars", engine({
39
48
  extname: ".handlebars",
package/lib/bucket.js CHANGED
@@ -6,6 +6,7 @@ import path from "path";
6
6
  import fs from 'fs';
7
7
  import os from 'os';
8
8
  import crypto from 'crypto';
9
+ import { appVersion, getLatestVersion } from "./config/index.js";
9
10
 
10
11
  const router = express.Router();
11
12
  const upload = multer({ storage: multer.memoryStorage() });
@@ -20,6 +21,16 @@ router.get('/mbkbucket', validateSessionAndRole('SuperAdmin'), async (req, res)
20
21
  renderPage(req, res, "bucket.handlebars", false, { page: "Admin Bucket", bucketvar: mbkautheVar?.bucket, message: req.query.message, error: req.query.error });
21
22
  });
22
23
 
24
+ router.get(['/mbkbucket/info', "/mbkbucket/i"], validateSessionAndRole('SuperAdmin'), async (req, res) => {
25
+ let latestVersion = 'unknown';
26
+ try {
27
+ latestVersion = await getLatestVersion();
28
+ } catch (err) {
29
+ console.error("[mbkauthe] Error fetching package-lock.json:", err);
30
+ }
31
+ renderPage(req, res, "info.handlebars", false, { page: "MBK Bucket Info", appVersion: appVersion, latestVersion, APP_NAME: mbkautheVar.APP_NAME });
32
+ });
33
+
23
34
  // API endpoint for fetching files
24
35
  router.get('/mbkbucket/api/files', validateSessionAndRole('SuperAdmin'), async (req, res) => {
25
36
  //mock response for testing
@@ -187,9 +198,9 @@ router.post('/mbkbucket/upload-complete', validateSessionAndRole('SuperAdmin'),
187
198
 
188
199
  // Cleanup chunks
189
200
  for (const f of files) {
190
- await fs.promises.unlink(path.join(dir, f)).catch(() => {});
201
+ await fs.promises.unlink(path.join(dir, f)).catch(() => { });
191
202
  }
192
- await fs.promises.rmdir(dir).catch(() => {});
203
+ await fs.promises.rmdir(dir).catch(() => { });
193
204
 
194
205
  return res.json({ success: true, message: 'File uploaded successfully (assembled)', key });
195
206
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mbkbucket",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "S3 Bucket manager for mbktech.org apps",
5
5
  "author": "Muhammad Bin Khalid",
6
6
  "homepage": "https://github.com/MIbnEKhalid/mbkbucket#readme",