blixify-server 0.2.0 → 0.2.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongoWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mongoWrapper.ts"],"names":[],"mappings":"AAUA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAGrD,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"mongoWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mongoWrapper.ts"],"names":[],"mappings":"AAUA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAGrD,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAkGD;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,EAAE,GAAG,CAAM;IAClB,UAAU,SAAM;IAChB,MAAM,UAAS;IACf,MAAM,EAAE,cAAc,CAQpB;IACF,GAAG,EAAE,UAAU,CAAC;IAChB,OAAO,SAAM;IACb,KAAK,SAAM;IACX,WAAW,EAAE,GAAG,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC;IAEX,YAAY,QAAS,GAAG,aAEtB;gBAGA,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,EACrD,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACzC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI;IAe3D,UAAU,SAAU,GAAG,SAIrB;IAEF,aAAa,YACF,GAAG,QACN,QAAQ,GAAG,QAAQ,GAAG,QAAQ,OAC/B,GAAG,UACA;QACN,GAAG,CAAC,EAAE,GAAG,CAAC;QACV,GAAG,CAAC,EAAE,GAAG,CAAC;KACX,mBA8CD;IAEF,eAAe,QACR,GAAG,OACH,GAAG,yBACc,GAAG,EAAE,KAAK,QAAQ,GAAG,CAAC;;mBAyE5C;IAEF,UAAU,QACH,GAAG,OACH,GAAG,qBACU,GAAG,KAAK,QAAQ,GAAG,CAAC;;mBAkDtC;IAEF,OAAO,QAAe,GAAG,OAAO,GAAG;;mBAgCjC;IAEF,eAAe,QACR,GAAG,OACH,GAAG,qBACU,GAAG,KAAK,QAAQ,GAAG,CAAC;;mBAyJtC;IAEF,UAAU,QACH,GAAG,OACH,GAAG,qBACU,GAAG,KAAK,QAAQ,GAAG,CAAC;;mBAqGtC;IAEF,eAAe,QACR,GAAG,OACH,GAAG,yBACc,GAAG,EAAE,KAAK,QAAQ,GAAG,CAAC;;mBAgI5C;IAEF,UAAU,QACH,GAAG,OACH,GAAG,qBACU,GAAG,KAAK,QAAQ,GAAG,CAAC;;mBAwCtC;IAEF,QAAQ,QAAe,GAAG,OAAO,GAAG;;;;;mBAoQlC;IAEF,IAAI,YA+EF;CACH"}
|
|
@@ -34,11 +34,8 @@ const handleParseQueryFilter = (queryList, prefix) => {
|
|
|
34
34
|
if (eachQuery.searchIds && eachQuery.searchIds.length > 0) {
|
|
35
35
|
eachQuery.searchIds.map((eachSearchId) => {
|
|
36
36
|
orOption = true;
|
|
37
|
-
let searchValue = value;
|
|
38
|
-
if (searchValue.includes("+"))
|
|
39
|
-
searchValue = "\\" + searchValue;
|
|
40
37
|
queryValues[eachSearchId] = {
|
|
41
|
-
$regex: `${
|
|
38
|
+
$regex: `${(0, utils_1.handleSpecialWordsEscapeRegex)(value)}`,
|
|
42
39
|
$options: "i",
|
|
43
40
|
};
|
|
44
41
|
});
|
|
@@ -360,7 +357,10 @@ class MongoWrapper {
|
|
|
360
357
|
if (eachQuery.searchIds && eachQuery.searchIds.length > 0) {
|
|
361
358
|
eachQuery.searchIds.map((eachSearchId) => {
|
|
362
359
|
queryFilter["$or"].push({
|
|
363
|
-
[eachSearchId]: {
|
|
360
|
+
[eachSearchId]: {
|
|
361
|
+
$regex: (0, utils_1.handleSpecialWordsEscapeRegex)(value),
|
|
362
|
+
$options: "i",
|
|
363
|
+
},
|
|
364
364
|
});
|
|
365
365
|
});
|
|
366
366
|
}
|
|
@@ -462,12 +462,15 @@ class MongoWrapper {
|
|
|
462
462
|
try {
|
|
463
463
|
const valid = this.modelChecker(req.body.data) && req.body.id;
|
|
464
464
|
if (valid) {
|
|
465
|
+
const upsert = req.body.upsert ? true : false;
|
|
466
|
+
let mongoData = {};
|
|
465
467
|
const mongoCollection = this.mongoDB
|
|
466
468
|
.db(this.tableId)
|
|
467
469
|
.collection(this.collection);
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
470
|
+
if (!upsert)
|
|
471
|
+
mongoData = yield mongoCollection.findOne({
|
|
472
|
+
_id: valid,
|
|
473
|
+
});
|
|
471
474
|
if (this.debug)
|
|
472
475
|
this.debug(req.body, mongoData);
|
|
473
476
|
//INFO : Security Checker
|
|
@@ -499,7 +502,7 @@ class MongoWrapper {
|
|
|
499
502
|
_id: valid,
|
|
500
503
|
}, {
|
|
501
504
|
$set: Object.assign({}, data),
|
|
502
|
-
}, { upsert:
|
|
505
|
+
}, { upsert: upsert });
|
|
503
506
|
if ((_j = req.body) === null || _j === void 0 ? void 0 : _j.stopRes)
|
|
504
507
|
return resBody;
|
|
505
508
|
res.send(resBody);
|
|
@@ -513,7 +516,7 @@ class MongoWrapper {
|
|
|
513
516
|
_id: valid,
|
|
514
517
|
}, {
|
|
515
518
|
$set: Object.assign({}, data),
|
|
516
|
-
}, { upsert:
|
|
519
|
+
}, { upsert: upsert });
|
|
517
520
|
if ((_k = req.body) === null || _k === void 0 ? void 0 : _k.stopRes)
|
|
518
521
|
return resBody;
|
|
519
522
|
res.send(resBody);
|
|
@@ -586,7 +589,10 @@ class MongoWrapper {
|
|
|
586
589
|
queryFilter["$or"] = [];
|
|
587
590
|
eachQuery.searchIds.map((eachSearchId) => {
|
|
588
591
|
queryFilter["$or"].push({
|
|
589
|
-
[eachSearchId]: {
|
|
592
|
+
[eachSearchId]: {
|
|
593
|
+
$regex: (0, utils_1.handleSpecialWordsEscapeRegex)(value),
|
|
594
|
+
$options: "i",
|
|
595
|
+
},
|
|
590
596
|
});
|
|
591
597
|
});
|
|
592
598
|
}
|
package/dist/apis/utils.d.ts
CHANGED
package/dist/apis/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/apis/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,aAAc,GAAG,eAAe,GAAG;;;;;;;CAoBnE,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/apis/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,aAAc,GAAG,eAAe,GAAG;;;;;;;CAoBnE,CAAC;AAEF,eAAO,MAAM,6BAA6B,WAAY,MAAM,WAE3D,CAAC"}
|
package/dist/apis/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compareUpdatedFields = void 0;
|
|
3
|
+
exports.handleSpecialWordsEscapeRegex = exports.compareUpdatedFields = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const compareUpdatedFields = (prevData, currentData) => {
|
|
6
6
|
const updatedFields = {};
|
|
@@ -19,3 +19,7 @@ const compareUpdatedFields = (prevData, currentData) => {
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
exports.compareUpdatedFields = compareUpdatedFields;
|
|
22
|
+
const handleSpecialWordsEscapeRegex = (string) => {
|
|
23
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
24
|
+
};
|
|
25
|
+
exports.handleSpecialWordsEscapeRegex = handleSpecialWordsEscapeRegex;
|