@stemy/backend 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.
@@ -972,30 +972,6 @@
972
972
  });
973
973
  return params;
974
974
  }
975
- function proxyFunction(name) {
976
- return function () {
977
- var args = Array.from(arguments);
978
- args.unshift(this);
979
- return this.helper[name].apply(this.helper, args);
980
- };
981
- }
982
- function proxyFunctions(schema, helper, paramName) {
983
- if (paramName === void 0) { paramName = null; }
984
- paramName = paramName || lcFirst(getConstructorName(helper)).replace(/helper$/gi, "");
985
- var descriptors = Object.getOwnPropertyDescriptors(helper.prototype);
986
- Object.keys(descriptors).forEach(function (name) {
987
- var func = descriptors[name].value;
988
- if (isFunction(func) && name !== "constructor") {
989
- var paramNames = getFunctionParams(func);
990
- if (paramNames[0] == paramName) {
991
- schema.methods[name] = proxyFunction(name);
992
- }
993
- }
994
- });
995
- injectServices(schema, {
996
- "helper": helper
997
- });
998
- }
999
975
  function ResolveEntity(model, extraCheck) {
1000
976
  var _this = this;
1001
977
  var modelName = model.modelName;
@@ -1740,6 +1716,7 @@
1740
1716
  case 1:
1741
1717
  _a.conn = (_b.sent()).connection;
1742
1718
  this.db = this.conn.db;
1719
+ console.log("DB INSTANCE", getType(this.db));
1743
1720
  this.fsBucket = new mongodb.GridFSBucket(this.db, { bucketName: "assets" });
1744
1721
  return [2 /*return*/];
1745
1722
  }
@@ -5196,29 +5173,39 @@
5196
5173
  }
5197
5174
  AuthController.prototype.login = function (credentials, res) {
5198
5175
  return __awaiter$6(this, void 0, void 0, function () {
5199
- var user, valid, _a, reason_1;
5200
- return __generator(this, function (_b) {
5201
- switch (_b.label) {
5176
+ var user, reason_1, valid, _a, _b;
5177
+ return __generator(this, function (_c) {
5178
+ switch (_c.label) {
5202
5179
  case 0:
5203
- _b.trys.push([0, 4, , 5]);
5204
- return [4 /*yield*/, this.userManager.getByCredentials(credentials)];
5180
+ user = null;
5181
+ _c.label = 1;
5205
5182
  case 1:
5206
- user = _b.sent();
5207
- return [4 /*yield*/, bcrypt.compare(credentials.password, user.password)];
5183
+ _c.trys.push([1, 3, , 4]);
5184
+ return [4 /*yield*/, this.userManager.getByCredentials(credentials)];
5208
5185
  case 2:
5209
- valid = _b.sent();
5186
+ user = _c.sent();
5187
+ return [3 /*break*/, 4];
5188
+ case 3:
5189
+ reason_1 = _c.sent();
5190
+ throw new routingControllers.HttpError(401, reason_1);
5191
+ case 4:
5192
+ if (!!user) return [3 /*break*/, 5];
5193
+ _a = false;
5194
+ return [3 /*break*/, 7];
5195
+ case 5: return [4 /*yield*/, bcrypt.compare(credentials.password, user.password)];
5196
+ case 6:
5197
+ _a = _c.sent();
5198
+ _c.label = 7;
5199
+ case 7:
5200
+ valid = _a;
5210
5201
  if (valid !== true)
5211
- throw "message.login.error";
5212
- _a = {
5202
+ throw new routingControllers.UnauthorizedError("message.login.error");
5203
+ _b = {
5213
5204
  token: jsonwebtoken.sign({ id: user._id || user.id }, this.config.resolve("jwtSecret"))
5214
5205
  };
5215
5206
  return [4 /*yield*/, this.userManager.serialize(user)];
5216
- case 3: return [2 /*return*/, (_a.user = _b.sent(),
5217
- _a)];
5218
- case 4:
5219
- reason_1 = _b.sent();
5220
- throw new routingControllers.HttpError(401, reason_1);
5221
- case 5: return [2 /*return*/];
5207
+ case 8: return [2 /*return*/, (_b.user = _c.sent(),
5208
+ _b)];
5222
5209
  }
5223
5210
  });
5224
5211
  });
@@ -6004,6 +5991,20 @@
6004
5991
  });
6005
5992
  }
6006
5993
 
5994
+ var BaseDoc = /** @class */ (function () {
5995
+ function BaseDoc() {
5996
+ }
5997
+ /**
5998
+ * Casts this to DocumentType<this> to allow using document methods in get/set-s
5999
+ */
6000
+ BaseDoc.prototype.cast = function () {
6001
+ return this;
6002
+ };
6003
+ return BaseDoc;
6004
+ }());
6005
+ var DocumentArray = mongoose.Types.DocumentArray;
6006
+ var PrimitiveArray = mongoose.Types.Array;
6007
+
6007
6008
  var __awaiter$1 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6008
6009
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6009
6010
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -6411,7 +6412,9 @@
6411
6412
  */
6412
6413
 
6413
6414
  exports.AssetImageParams = AssetImageParams;
6415
+ exports.BaseDoc = BaseDoc;
6414
6416
  exports.DI_CONTAINER = DI_CONTAINER;
6417
+ exports.DocumentArray = DocumentArray;
6415
6418
  exports.EXPRESS = EXPRESS;
6416
6419
  exports.FIXTURE = FIXTURE;
6417
6420
  exports.HTTP_SERVER = HTTP_SERVER;
@@ -6419,6 +6422,7 @@
6419
6422
  exports.LazyAssetGenerator = LazyAssetGenerator;
6420
6423
  exports.PARAMETER = PARAMETER;
6421
6424
  exports.Parameter = Parameter;
6425
+ exports.PrimitiveArray = PrimitiveArray;
6422
6426
  exports.ResolveEntity = ResolveEntity;
6423
6427
  exports.SOCKET_SERVER = SOCKET_SERVER;
6424
6428
  exports.Type = Type;
@@ -6476,8 +6480,6 @@
6476
6480
  exports.paginateAggregations = paginateAggregations;
6477
6481
  exports.projectStage = projectStage;
6478
6482
  exports.promiseTimeout = promiseTimeout;
6479
- exports.proxyFunction = proxyFunction;
6480
- exports.proxyFunctions = proxyFunctions;
6481
6483
  exports.rand = rand;
6482
6484
  exports.random = random;
6483
6485
  exports.readAndDeleteFile = readAndDeleteFile;