@adminforth/storage-adapter-local 1.0.6 → 1.0.8

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/dist/index.js CHANGED
@@ -197,12 +197,12 @@ class AdminForthStorageAdapterLocalFilesystem {
197
197
  this.expressBase = `${slashedPrefix}uploaded-static/${userUniqueIntanceId}`;
198
198
  }
199
199
  else {
200
- if (AdminForthStorageAdapterLocalFilesystem.registredPrexises.includes(this.options.adminServeBaseUrl)) {
200
+ if (AdminForthStorageAdapterLocalFilesystem.registredPrexises.includes(this.options.adminServeBaseUrl) || AdminForthStorageAdapterLocalFilesystem.registredPrexises.includes(`/${this.options.adminServeBaseUrl}`)) {
201
201
  throw new Error(`adminServeBaseUrl ${this.options.adminServeBaseUrl} already registered, by another instance of local filesystem adapter.
202
202
  Each adapter instahce should have unique adminServeBaseUrl by design.
203
203
  `);
204
204
  }
205
- AdminForthStorageAdapterLocalFilesystem.registredPrexises.push(this.expressBase);
205
+ AdminForthStorageAdapterLocalFilesystem.registredPrexises.push(this.options.adminServeBaseUrl);
206
206
  this.expressBase = `${slashedPrefix}${this.options.adminServeBaseUrl}`;
207
207
  }
208
208
  // add express PUT endpoint for uploading files
@@ -225,7 +225,6 @@ class AdminForthStorageAdapterLocalFilesystem {
225
225
  const payload = {
226
226
  contentType: contentType,
227
227
  };
228
- console.log(`👐👐👐 verify sign for ${key}|${expires}|${JSON.stringify(payload)}`);
229
228
  const expectedSignature = this.sign(`${this.expressBase}/${key}`, expires, payload);
230
229
  if (signature !== expectedSignature) {
231
230
  return res.status(403).send("Invalid signature");
@@ -270,10 +269,8 @@ class AdminForthStorageAdapterLocalFilesystem {
270
269
  res.status(200).send("File uploaded");
271
270
  });
272
271
  }));
273
- console.log(`🎉🎉🎉 registring get endpoint for ${this.expressBase}/*`);
274
272
  // add express GET endpoint for downloading files
275
273
  expressInstance.get(`${this.expressBase}/*`, (req, res) => __awaiter(this, void 0, void 0, function* () {
276
- console.log(`🎉🎉🎉 GET ${req.url}`, res, typeof res, Object.keys(res));
277
274
  const key = req.params[0];
278
275
  const filePath = path.resolve(this.options.fileSystemFolder, key);
279
276
  // Ensure filePath is within fileSystemFolder
package/index.ts CHANGED
@@ -217,13 +217,13 @@ export default class AdminForthStorageAdapterLocalFilesystem implements StorageA
217
217
  if (!this.options.adminServeBaseUrl) {
218
218
  this.expressBase = `${slashedPrefix}uploaded-static/${userUniqueIntanceId}`
219
219
  } else {
220
- if (AdminForthStorageAdapterLocalFilesystem.registredPrexises.includes(this.options.adminServeBaseUrl)) {
220
+ if (AdminForthStorageAdapterLocalFilesystem.registredPrexises.includes(this.options.adminServeBaseUrl) || AdminForthStorageAdapterLocalFilesystem.registredPrexises.includes(`/${this.options.adminServeBaseUrl}`)) {
221
221
  throw new Error(`adminServeBaseUrl ${this.options.adminServeBaseUrl} already registered, by another instance of local filesystem adapter.
222
222
  Each adapter instahce should have unique adminServeBaseUrl by design.
223
223
  `);
224
224
  }
225
225
 
226
- AdminForthStorageAdapterLocalFilesystem.registredPrexises.push(this.expressBase);
226
+ AdminForthStorageAdapterLocalFilesystem.registredPrexises.push(this.options.adminServeBaseUrl);
227
227
  this.expressBase = `${slashedPrefix}${this.options.adminServeBaseUrl}`;
228
228
 
229
229
  }
@@ -253,7 +253,6 @@ export default class AdminForthStorageAdapterLocalFilesystem implements StorageA
253
253
  const payload = {
254
254
  contentType: contentType,
255
255
  }
256
- console.log(`👐👐👐 verify sign for ${key}|${expires}|${JSON.stringify(payload)}`)
257
256
 
258
257
  const expectedSignature = this.sign(
259
258
  `${this.expressBase}/${key}`, expires, payload);
@@ -304,10 +303,8 @@ export default class AdminForthStorageAdapterLocalFilesystem implements StorageA
304
303
  });
305
304
  });
306
305
 
307
- console.log(`🎉🎉🎉 registring get endpoint for ${this.expressBase}/*`)
308
306
  // add express GET endpoint for downloading files
309
307
  expressInstance.get(`${this.expressBase}/*`, async (req: any, res: any) => {
310
- console.log(`🎉🎉🎉 GET ${req.url}`, res, typeof res, Object.keys(res));
311
308
  const key = req.params[0];
312
309
  const filePath = path.resolve(this.options.fileSystemFolder, key);
313
310
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/storage-adapter-local",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -25,6 +25,6 @@
25
25
  "typescript": "^5.8.2"
26
26
  },
27
27
  "peerDependencies": {
28
- "adminforth": "^2.13.0-next.56"
28
+ "adminforth": "next"
29
29
  }
30
30
  }