@terreno/admin-backend 0.13.0 → 0.13.1

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/adminApp.js CHANGED
@@ -473,20 +473,21 @@ var AdminApp = /** @class */ (function () {
473
473
  searchableFields: searchableFields,
474
474
  });
475
475
  app.get("".concat(basePath).concat(config.routePath, "/search"), (0, api_1.authenticateMiddleware)(), (0, api_1.asyncHandler)(function (req, res) { return __awaiter(_this, void 0, void 0, function () {
476
- var q, escapedQ, regex, fields, orConditions, objectIdFields_1, objectIdFields_1_1, field, results, err_1;
476
+ var user, q, escapedQ, regex, fields, orConditions, objectIdFields_1, objectIdFields_1_1, field, results, err_1;
477
477
  var e_9, _a, _b;
478
- var _c, _d;
479
- return __generator(this, function (_e) {
480
- switch (_e.label) {
478
+ var _c;
479
+ return __generator(this, function (_d) {
480
+ switch (_d.label) {
481
481
  case 0:
482
- if (!((_c = req.user) === null || _c === void 0 ? void 0 : _c.admin)) {
482
+ user = req.user;
483
+ if (!(user === null || user === void 0 ? void 0 : user.admin)) {
483
484
  throw new api_1.APIError({
484
485
  disableExternalErrorTracking: true,
485
486
  status: 403,
486
487
  title: "Forbidden",
487
488
  });
488
489
  }
489
- q = String((_d = req.query.q) !== null && _d !== void 0 ? _d : "");
490
+ q = String((_c = req.query.q) !== null && _c !== void 0 ? _c : "");
490
491
  if (!q) {
491
492
  return [2 /*return*/, res.json({ data: [] })];
492
493
  }
@@ -523,19 +524,19 @@ var AdminApp = /** @class */ (function () {
523
524
  model: config.model.modelName,
524
525
  q: q,
525
526
  });
526
- _e.label = 1;
527
+ _d.label = 1;
527
528
  case 1:
528
- _e.trys.push([1, 3, , 4]);
529
+ _d.trys.push([1, 3, , 4]);
529
530
  return [4 /*yield*/, config.model.find({ $or: orConditions }).limit(20).lean()];
530
531
  case 2:
531
- results = _e.sent();
532
+ results = _d.sent();
532
533
  api_1.logger.debug("Admin search results", {
533
534
  count: results.length,
534
535
  model: config.model.modelName,
535
536
  });
536
537
  return [2 /*return*/, res.json({ data: results })];
537
538
  case 3:
538
- err_1 = _e.sent();
539
+ err_1 = _d.sent();
539
540
  api_1.logger.error("Admin search failed", {
540
541
  error: err_1,
541
542
  fields: fields,
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "dependencies": {
7
7
  "@google-cloud/storage": "^7.15.0",
8
- "@terreno/api": "0.13.0",
8
+ "@terreno/api": "0.13.1",
9
9
  "express": "^5.2.1",
10
10
  "luxon": "^3.7.2",
11
11
  "multer": "^1.4.5-lts.1"
@@ -53,5 +53,5 @@
53
53
  "test:coverage": "bun run ../scripts/check-coverage.ts"
54
54
  },
55
55
  "types": "dist/index.d.ts",
56
- "version": "0.13.0"
56
+ "version": "0.13.1"
57
57
  }
package/src/adminApp.ts CHANGED
@@ -484,7 +484,8 @@ export class AdminApp {
484
484
  `${basePath}${config.routePath}/search`,
485
485
  authenticateMiddleware(),
486
486
  asyncHandler(async (req, res) => {
487
- if (!(req as any).user?.admin) {
487
+ const user = req.user as {_id: unknown; admin?: boolean} | undefined;
488
+ if (!user?.admin) {
488
489
  throw new APIError({
489
490
  disableExternalErrorTracking: true,
490
491
  status: 403,