@7365admin1/core 3.41.1 → 3.42.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +22 -1
- package/dist/index.js +272 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +518 -260
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -537,13 +537,13 @@ var require_logger = __commonJS({
|
|
|
537
537
|
"use strict";
|
|
538
538
|
exports.__esModule = true;
|
|
539
539
|
var _utils = require_utils();
|
|
540
|
-
var
|
|
540
|
+
var logger202 = {
|
|
541
541
|
methodMap: ["debug", "info", "warn", "error"],
|
|
542
542
|
level: "info",
|
|
543
543
|
// Maps a given level value to the `methodMap` indexes above.
|
|
544
544
|
lookupLevel: function lookupLevel(level) {
|
|
545
545
|
if (typeof level === "string") {
|
|
546
|
-
var levelMap = _utils.indexOf(
|
|
546
|
+
var levelMap = _utils.indexOf(logger202.methodMap, level.toLowerCase());
|
|
547
547
|
if (levelMap >= 0) {
|
|
548
548
|
level = levelMap;
|
|
549
549
|
} else {
|
|
@@ -554,9 +554,9 @@ var require_logger = __commonJS({
|
|
|
554
554
|
},
|
|
555
555
|
// Can be overridden in the host environment
|
|
556
556
|
log: function log(level) {
|
|
557
|
-
level =
|
|
558
|
-
if (typeof console !== "undefined" &&
|
|
559
|
-
var method =
|
|
557
|
+
level = logger202.lookupLevel(level);
|
|
558
|
+
if (typeof console !== "undefined" && logger202.lookupLevel(logger202.level) <= level) {
|
|
559
|
+
var method = logger202.methodMap[level];
|
|
560
560
|
if (!console[method]) {
|
|
561
561
|
method = "log";
|
|
562
562
|
}
|
|
@@ -567,7 +567,7 @@ var require_logger = __commonJS({
|
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
569
|
};
|
|
570
|
-
exports["default"] =
|
|
570
|
+
exports["default"] = logger202;
|
|
571
571
|
module.exports = exports["default"];
|
|
572
572
|
}
|
|
573
573
|
});
|
|
@@ -65066,9 +65066,19 @@ import { ObjectId as ObjectId135 } from "mongodb";
|
|
|
65066
65066
|
import { BadRequestError as BadRequestError199, logger as logger178 } from "@7365admin1/node-server-utils";
|
|
65067
65067
|
import { ObjectId as ObjectId134 } from "mongodb";
|
|
65068
65068
|
import Joi126 from "joi";
|
|
65069
|
+
var BillingPaymentStatus = /* @__PURE__ */ ((BillingPaymentStatus2) => {
|
|
65070
|
+
BillingPaymentStatus2["PENDING"] = "pending";
|
|
65071
|
+
BillingPaymentStatus2["SUCCESS"] = "success";
|
|
65072
|
+
BillingPaymentStatus2["FAILED"] = "failed";
|
|
65073
|
+
BillingPaymentStatus2["PARTIAL"] = "partial";
|
|
65074
|
+
BillingPaymentStatus2["CANCELLED"] = "cancelled";
|
|
65075
|
+
return BillingPaymentStatus2;
|
|
65076
|
+
})(BillingPaymentStatus || {});
|
|
65069
65077
|
var schemaBillingItems = Joi126.object({
|
|
65070
65078
|
_id: Joi126.string().hex().optional(),
|
|
65071
|
-
name: Joi126.string().optional().allow(null, "")
|
|
65079
|
+
name: Joi126.string().optional().allow(null, ""),
|
|
65080
|
+
amount: Joi126.number().optional().allow(null, ""),
|
|
65081
|
+
referenceNumber: Joi126.string().optional().allow(null, "")
|
|
65072
65082
|
});
|
|
65073
65083
|
var schemaBillingPayments = Joi126.object({
|
|
65074
65084
|
_id: Joi126.string().hex().optional(),
|
|
@@ -65159,7 +65169,9 @@ import {
|
|
|
65159
65169
|
useAtlas as useAtlas114,
|
|
65160
65170
|
logger as logger179,
|
|
65161
65171
|
BadRequestError as BadRequestError200,
|
|
65162
|
-
|
|
65172
|
+
NotFoundError as NotFoundError53,
|
|
65173
|
+
AppError as AppError28,
|
|
65174
|
+
paginate as paginate60
|
|
65163
65175
|
} from "@7365admin1/node-server-utils";
|
|
65164
65176
|
var useRedDotPaymentRepo = () => {
|
|
65165
65177
|
const getDB2 = () => {
|
|
@@ -65181,12 +65193,60 @@ var useRedDotPaymentRepo = () => {
|
|
|
65181
65193
|
const redDotMerchantCollection = () => {
|
|
65182
65194
|
return getDB2().collection("payment-gateways");
|
|
65183
65195
|
};
|
|
65196
|
+
async function createIndexes() {
|
|
65197
|
+
try {
|
|
65198
|
+
await paymentCollection().createIndexes([
|
|
65199
|
+
// A referenceNumber-prefixed compound index serves both the lookup by
|
|
65200
|
+
// reference alone and the { referenceNumber, status } lookups used by
|
|
65201
|
+
// the pay single / pay multiple flows.
|
|
65202
|
+
{
|
|
65203
|
+
key: { referenceNumber: 1, status: 1 },
|
|
65204
|
+
name: "referenceNumber_1_status_1"
|
|
65205
|
+
}
|
|
65206
|
+
]);
|
|
65207
|
+
} catch (error) {
|
|
65208
|
+
logger179.log({
|
|
65209
|
+
level: "error",
|
|
65210
|
+
message: error.message
|
|
65211
|
+
});
|
|
65212
|
+
throw new InternalServerError68(
|
|
65213
|
+
"Failed to create index on billing payments."
|
|
65214
|
+
);
|
|
65215
|
+
}
|
|
65216
|
+
}
|
|
65217
|
+
async function getPaymentByReference(referenceNumber, session) {
|
|
65218
|
+
const reference = typeof referenceNumber === "string" ? referenceNumber.trim() : "";
|
|
65219
|
+
if (!reference) {
|
|
65220
|
+
throw new BadRequestError200("Reference number is required.");
|
|
65221
|
+
}
|
|
65222
|
+
try {
|
|
65223
|
+
const payment = await paymentCollection().findOne(
|
|
65224
|
+
{
|
|
65225
|
+
referenceNumber: reference
|
|
65226
|
+
},
|
|
65227
|
+
{ session }
|
|
65228
|
+
);
|
|
65229
|
+
if (!payment) {
|
|
65230
|
+
throw new NotFoundError53("Payment not found.");
|
|
65231
|
+
}
|
|
65232
|
+
return payment;
|
|
65233
|
+
} catch (error) {
|
|
65234
|
+
if (error instanceof AppError28) {
|
|
65235
|
+
throw error;
|
|
65236
|
+
}
|
|
65237
|
+
logger179.log({
|
|
65238
|
+
level: "error",
|
|
65239
|
+
message: error.message
|
|
65240
|
+
});
|
|
65241
|
+
throw new InternalServerError68("Failed to get payment.");
|
|
65242
|
+
}
|
|
65243
|
+
}
|
|
65184
65244
|
async function createPayment(type, payload, session) {
|
|
65185
65245
|
if (type == "single") {
|
|
65186
65246
|
try {
|
|
65187
65247
|
payload = MBillingItems(payload);
|
|
65188
|
-
|
|
65189
|
-
return
|
|
65248
|
+
await paymentCollection().insertOne(payload, { session });
|
|
65249
|
+
return payload.referenceNumber;
|
|
65190
65250
|
} catch (error) {
|
|
65191
65251
|
logger179.log({
|
|
65192
65252
|
level: "error",
|
|
@@ -65215,7 +65275,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
65215
65275
|
{ $set: { referenceNumber } },
|
|
65216
65276
|
{ session }
|
|
65217
65277
|
);
|
|
65218
|
-
return
|
|
65278
|
+
return referenceNumber;
|
|
65219
65279
|
} catch (error) {
|
|
65220
65280
|
logger179.log({
|
|
65221
65281
|
level: "error",
|
|
@@ -65233,6 +65293,76 @@ var useRedDotPaymentRepo = () => {
|
|
|
65233
65293
|
}
|
|
65234
65294
|
}
|
|
65235
65295
|
}
|
|
65296
|
+
async function getPaidBills({
|
|
65297
|
+
search = "",
|
|
65298
|
+
page = 1,
|
|
65299
|
+
limit = 10,
|
|
65300
|
+
sort = {},
|
|
65301
|
+
month,
|
|
65302
|
+
year,
|
|
65303
|
+
unitId
|
|
65304
|
+
}, session) {
|
|
65305
|
+
let _unitId;
|
|
65306
|
+
try {
|
|
65307
|
+
_unitId = new ObjectId135(unitId);
|
|
65308
|
+
} catch {
|
|
65309
|
+
throw new BadRequestError200("Invalid unit ID format.");
|
|
65310
|
+
}
|
|
65311
|
+
page = page > 0 ? page - 1 : 0;
|
|
65312
|
+
let dateExpr = {};
|
|
65313
|
+
const datePaidRange = buildDatePaidRange(month, year);
|
|
65314
|
+
if (datePaidRange) {
|
|
65315
|
+
dateExpr.datePaid = datePaidRange;
|
|
65316
|
+
}
|
|
65317
|
+
const query = {
|
|
65318
|
+
unitId: _unitId,
|
|
65319
|
+
status: "success",
|
|
65320
|
+
...search && {
|
|
65321
|
+
$or: [
|
|
65322
|
+
{ referenceNumber: { $regex: search, $options: "i" } },
|
|
65323
|
+
{ unitOwner: { $regex: search, $options: "i" } },
|
|
65324
|
+
{ method: { $regex: search, $options: "i" } },
|
|
65325
|
+
{ transaction_id: { $regex: search, $options: "i" } },
|
|
65326
|
+
{ "unitBillingItems.name": { $regex: search, $options: "i" } },
|
|
65327
|
+
{
|
|
65328
|
+
$expr: {
|
|
65329
|
+
$regexMatch: {
|
|
65330
|
+
input: { $toString: "$totalAmount" },
|
|
65331
|
+
regex: search,
|
|
65332
|
+
options: "i"
|
|
65333
|
+
}
|
|
65334
|
+
}
|
|
65335
|
+
}
|
|
65336
|
+
]
|
|
65337
|
+
},
|
|
65338
|
+
...dateExpr
|
|
65339
|
+
};
|
|
65340
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
65341
|
+
try {
|
|
65342
|
+
const basePipeline = [
|
|
65343
|
+
{ $match: query },
|
|
65344
|
+
{ $sort: sort },
|
|
65345
|
+
{ $skip: page * limit },
|
|
65346
|
+
{ $limit: limit }
|
|
65347
|
+
];
|
|
65348
|
+
const [items, countResult] = await Promise.all([
|
|
65349
|
+
paymentCollection().aggregate(basePipeline, { session }).toArray(),
|
|
65350
|
+
paymentCollection().aggregate([{ $match: query }, { $count: "total" }], { session }).toArray()
|
|
65351
|
+
]);
|
|
65352
|
+
const totalCount = countResult[0]?.total || 0;
|
|
65353
|
+
const data = paginate60(items, page, limit, totalCount);
|
|
65354
|
+
return data;
|
|
65355
|
+
} catch (error) {
|
|
65356
|
+
if (error instanceof AppError28) {
|
|
65357
|
+
throw error;
|
|
65358
|
+
}
|
|
65359
|
+
logger179.log({
|
|
65360
|
+
level: "error",
|
|
65361
|
+
message: error.message
|
|
65362
|
+
});
|
|
65363
|
+
throw new InternalServerError68("Failed to retrieve paid bills.");
|
|
65364
|
+
}
|
|
65365
|
+
}
|
|
65236
65366
|
async function paySingleUnitBill(refId, payload) {
|
|
65237
65367
|
const session = useAtlas114.getClient()?.startSession();
|
|
65238
65368
|
try {
|
|
@@ -65395,6 +65525,52 @@ var useRedDotPaymentRepo = () => {
|
|
|
65395
65525
|
session?.endSession();
|
|
65396
65526
|
}
|
|
65397
65527
|
}
|
|
65528
|
+
function buildDatePaidRange(month, year) {
|
|
65529
|
+
if (!year)
|
|
65530
|
+
return null;
|
|
65531
|
+
const yearNum = Number(year);
|
|
65532
|
+
if (!Number.isInteger(yearNum) || yearNum < 1970 || yearNum > 9999) {
|
|
65533
|
+
throw new BadRequestError200("Invalid year filter.");
|
|
65534
|
+
}
|
|
65535
|
+
if (month) {
|
|
65536
|
+
const monthNum = Number(month);
|
|
65537
|
+
if (!Number.isInteger(monthNum) || monthNum < 1 || monthNum > 12) {
|
|
65538
|
+
throw new BadRequestError200("Invalid month filter.");
|
|
65539
|
+
}
|
|
65540
|
+
return {
|
|
65541
|
+
$gte: new Date(yearNum, monthNum - 1, 1),
|
|
65542
|
+
$lt: new Date(yearNum, monthNum, 1)
|
|
65543
|
+
};
|
|
65544
|
+
}
|
|
65545
|
+
return {
|
|
65546
|
+
$gte: new Date(yearNum, 0, 1),
|
|
65547
|
+
$lt: new Date(yearNum + 1, 0, 1)
|
|
65548
|
+
};
|
|
65549
|
+
}
|
|
65550
|
+
async function updateStatus(referenceNumber, status, session) {
|
|
65551
|
+
const reference = typeof referenceNumber === "string" ? referenceNumber.trim() : "";
|
|
65552
|
+
if (!reference) {
|
|
65553
|
+
throw new BadRequestError200("Reference number is required.");
|
|
65554
|
+
}
|
|
65555
|
+
try {
|
|
65556
|
+
const res = await paymentCollection().updateOne(
|
|
65557
|
+
{ referenceNumber: reference, status: "pending" },
|
|
65558
|
+
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
65559
|
+
{ session }
|
|
65560
|
+
);
|
|
65561
|
+
if (res.matchedCount === 0) {
|
|
65562
|
+
throw new NotFoundError53(
|
|
65563
|
+
"Payment not found or is no longer pending."
|
|
65564
|
+
);
|
|
65565
|
+
}
|
|
65566
|
+
return res;
|
|
65567
|
+
} catch (error) {
|
|
65568
|
+
if (error instanceof AppError28) {
|
|
65569
|
+
throw error;
|
|
65570
|
+
}
|
|
65571
|
+
throw new InternalServerError68("Failed to update payment status.");
|
|
65572
|
+
}
|
|
65573
|
+
}
|
|
65398
65574
|
function formatDateString(today) {
|
|
65399
65575
|
today = typeof today === "string" ? new Date(today) : today;
|
|
65400
65576
|
let month = today.getMonth() + 1;
|
|
@@ -65403,7 +65579,15 @@ var useRedDotPaymentRepo = () => {
|
|
|
65403
65579
|
const formattedDate = `${month.toString().padStart(2, "0")}${day.toString().padStart(2, "0")}${year}`;
|
|
65404
65580
|
return formattedDate;
|
|
65405
65581
|
}
|
|
65406
|
-
return {
|
|
65582
|
+
return {
|
|
65583
|
+
paySingleUnitBill,
|
|
65584
|
+
createPayment,
|
|
65585
|
+
payMultipleUnitBill,
|
|
65586
|
+
getPaidBills,
|
|
65587
|
+
createIndexes,
|
|
65588
|
+
getPaymentByReference,
|
|
65589
|
+
updateStatus
|
|
65590
|
+
};
|
|
65407
65591
|
};
|
|
65408
65592
|
|
|
65409
65593
|
// src/services/reddot-payment.service.ts
|
|
@@ -65513,7 +65697,7 @@ var useRedDotPaymentSvc = () => {
|
|
|
65513
65697
|
const success = {
|
|
65514
65698
|
...basePayload,
|
|
65515
65699
|
paymentStatus: "paid" /* PAID */,
|
|
65516
|
-
amountPaid:
|
|
65700
|
+
amountPaid: Number(amount)
|
|
65517
65701
|
};
|
|
65518
65702
|
if (isBulk) {
|
|
65519
65703
|
await payMultipleUnitBill(refId, success);
|
|
@@ -65545,9 +65729,14 @@ var useRedDotPaymentSvc = () => {
|
|
|
65545
65729
|
|
|
65546
65730
|
// src/controllers/reddot-payment.controller.ts
|
|
65547
65731
|
import Joi127 from "joi";
|
|
65548
|
-
import { BadRequestError as BadRequestError201 } from "@7365admin1/node-server-utils";
|
|
65732
|
+
import { BadRequestError as BadRequestError201, logger as logger180 } from "@7365admin1/node-server-utils";
|
|
65549
65733
|
function useRedDotPaymentController() {
|
|
65550
|
-
const {
|
|
65734
|
+
const {
|
|
65735
|
+
createPayment: _createPayment,
|
|
65736
|
+
updateStatus: _updateStatus,
|
|
65737
|
+
getPaymentByReference: _getPaymentByReference,
|
|
65738
|
+
getPaidBills: _getPaidBills
|
|
65739
|
+
} = useRedDotPaymentRepo();
|
|
65551
65740
|
const redirectPaymentTransaction = async (req, res) => {
|
|
65552
65741
|
try {
|
|
65553
65742
|
const data = req.body;
|
|
@@ -65611,17 +65800,86 @@ function useRedDotPaymentController() {
|
|
|
65611
65800
|
try {
|
|
65612
65801
|
const payment = await _createPayment(type, value);
|
|
65613
65802
|
res.status(201).json({
|
|
65614
|
-
message: "
|
|
65803
|
+
message: "success",
|
|
65615
65804
|
data: payment
|
|
65616
65805
|
});
|
|
65617
65806
|
} catch (error) {
|
|
65618
|
-
|
|
65807
|
+
const status = error?.statusCode ?? 500;
|
|
65808
|
+
res.status(status).json({ message: "failed" });
|
|
65809
|
+
}
|
|
65810
|
+
}
|
|
65811
|
+
async function updateStatus(req, res, next) {
|
|
65812
|
+
const schema2 = Joi127.object({
|
|
65813
|
+
referenceNumber: Joi127.string().required(),
|
|
65814
|
+
status: Joi127.string().valid(...Object.values(BillingPaymentStatus)).required()
|
|
65815
|
+
});
|
|
65816
|
+
const { error, value } = schema2.validate({
|
|
65817
|
+
referenceNumber: req.params.id,
|
|
65818
|
+
status: req.body.status
|
|
65819
|
+
});
|
|
65820
|
+
if (error) {
|
|
65821
|
+
logger180.log({ level: "error", message: error.message });
|
|
65822
|
+
next(new BadRequestError201(error.message));
|
|
65823
|
+
return;
|
|
65824
|
+
}
|
|
65825
|
+
try {
|
|
65826
|
+
const data = await _updateStatus(value.referenceNumber, value.status);
|
|
65827
|
+
res.status(200).json({ message: "success", data });
|
|
65828
|
+
return;
|
|
65829
|
+
} catch (error2) {
|
|
65830
|
+
logger180.log({ level: "error", message: error2.message });
|
|
65831
|
+
next(error2);
|
|
65832
|
+
return;
|
|
65833
|
+
}
|
|
65834
|
+
}
|
|
65835
|
+
async function getPaymentByReference(req, res, next) {
|
|
65836
|
+
const schema2 = Joi127.object({
|
|
65837
|
+
referenceNumber: Joi127.string().required()
|
|
65838
|
+
});
|
|
65839
|
+
const { error, value } = schema2.validate(req.params);
|
|
65840
|
+
if (error) {
|
|
65841
|
+
next(new BadRequestError201(error.message));
|
|
65842
|
+
return;
|
|
65843
|
+
}
|
|
65844
|
+
try {
|
|
65845
|
+
const payment = await _getPaymentByReference(value.referenceNumber);
|
|
65846
|
+
res.json({ data: payment });
|
|
65847
|
+
return;
|
|
65848
|
+
} catch (error2) {
|
|
65849
|
+
next(error2);
|
|
65850
|
+
return;
|
|
65851
|
+
}
|
|
65852
|
+
}
|
|
65853
|
+
async function getPaidBills(req, res, next) {
|
|
65854
|
+
const schema2 = Joi127.object({
|
|
65855
|
+
unitId: Joi127.string().hex().length(24).required(),
|
|
65856
|
+
page: Joi127.number().integer().min(1).default(1),
|
|
65857
|
+
limit: Joi127.number().integer().min(1).max(100).default(10),
|
|
65858
|
+
search: Joi127.string().trim().allow("").default(""),
|
|
65859
|
+
month: Joi127.string().pattern(/^(0?[1-9]|1[0-2])$/).allow("").optional(),
|
|
65860
|
+
year: Joi127.string().pattern(/^\d{4}$/).allow("").optional()
|
|
65861
|
+
});
|
|
65862
|
+
const { error, value } = schema2.validate({ ...req.params, ...req.query });
|
|
65863
|
+
if (error) {
|
|
65864
|
+
next(new BadRequestError201(error.message));
|
|
65865
|
+
return;
|
|
65866
|
+
}
|
|
65867
|
+
try {
|
|
65868
|
+
const bills = await _getPaidBills(value);
|
|
65869
|
+
res.json({ data: bills });
|
|
65870
|
+
return;
|
|
65871
|
+
} catch (error2) {
|
|
65872
|
+
next(error2);
|
|
65873
|
+
return;
|
|
65619
65874
|
}
|
|
65620
65875
|
}
|
|
65621
65876
|
return {
|
|
65622
65877
|
redirectPaymentTransaction,
|
|
65623
65878
|
enquirePaymentTransaction,
|
|
65624
|
-
createPayment
|
|
65879
|
+
createPayment,
|
|
65880
|
+
getPaymentByReference,
|
|
65881
|
+
updateStatus,
|
|
65882
|
+
getPaidBills
|
|
65625
65883
|
};
|
|
65626
65884
|
}
|
|
65627
65885
|
|
|
@@ -65629,10 +65887,10 @@ function useRedDotPaymentController() {
|
|
|
65629
65887
|
import {
|
|
65630
65888
|
useMailer as useMailer5,
|
|
65631
65889
|
compileHandlebar as compileHandlebar5,
|
|
65632
|
-
logger as
|
|
65890
|
+
logger as logger181,
|
|
65633
65891
|
getDirectory as getDirectory5,
|
|
65634
65892
|
BadRequestError as BadRequestError202,
|
|
65635
|
-
NotFoundError as
|
|
65893
|
+
NotFoundError as NotFoundError54,
|
|
65636
65894
|
InternalServerError as InternalServerError70,
|
|
65637
65895
|
useAtlas as useAtlas116,
|
|
65638
65896
|
hashPassword as hashPassword4
|
|
@@ -65744,7 +66002,7 @@ function useVerificationServiceV2() {
|
|
|
65744
66002
|
html: emailContent,
|
|
65745
66003
|
sender: "iService365" /* ISERVICE365 */
|
|
65746
66004
|
}).catch((error) => {
|
|
65747
|
-
|
|
66005
|
+
logger181.log({
|
|
65748
66006
|
level: "error",
|
|
65749
66007
|
message: `Error sending user invite email: ${error}`
|
|
65750
66008
|
});
|
|
@@ -65764,7 +66022,7 @@ function useVerificationServiceV2() {
|
|
|
65764
66022
|
session?.startTransaction();
|
|
65765
66023
|
const item = await _getByVerificationCode(verificationCode);
|
|
65766
66024
|
if (!item) {
|
|
65767
|
-
throw new
|
|
66025
|
+
throw new NotFoundError54("Verification not found.");
|
|
65768
66026
|
}
|
|
65769
66027
|
switch (item.status) {
|
|
65770
66028
|
case "expired" /* EXPIRED */:
|
|
@@ -65789,7 +66047,7 @@ function useVerificationServiceV2() {
|
|
|
65789
66047
|
return { _id, type, email, status, expireAt };
|
|
65790
66048
|
} catch (error) {
|
|
65791
66049
|
await session?.abortTransaction();
|
|
65792
|
-
|
|
66050
|
+
logger181.log({
|
|
65793
66051
|
level: "info",
|
|
65794
66052
|
message: `Error verifying user invitation: ${error}`
|
|
65795
66053
|
});
|
|
@@ -65844,7 +66102,7 @@ function useVerificationServiceV2() {
|
|
|
65844
66102
|
html: emailContent,
|
|
65845
66103
|
sender: "iService365" /* ISERVICE365 */
|
|
65846
66104
|
}).catch((error) => {
|
|
65847
|
-
|
|
66105
|
+
logger181.log({
|
|
65848
66106
|
level: "error",
|
|
65849
66107
|
message: `Error sending user ${type} email: ${error}`
|
|
65850
66108
|
});
|
|
@@ -65874,7 +66132,7 @@ function useVerificationServiceV2() {
|
|
|
65874
66132
|
});
|
|
65875
66133
|
if (error) {
|
|
65876
66134
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
65877
|
-
|
|
66135
|
+
logger181.log({ level: "error", message: messages });
|
|
65878
66136
|
throw new BadRequestError202(`Invalid input: ${error.message}`);
|
|
65879
66137
|
}
|
|
65880
66138
|
let subject = "Service Provider Invite" /* _SERVICE_PROVIDER_INVITE */;
|
|
@@ -65980,7 +66238,7 @@ function useVerificationServiceV2() {
|
|
|
65980
66238
|
sender: "iService365" /* ISERVICE365 */,
|
|
65981
66239
|
html: emailContent
|
|
65982
66240
|
}).catch((error) => {
|
|
65983
|
-
|
|
66241
|
+
logger181.log({
|
|
65984
66242
|
level: "error",
|
|
65985
66243
|
message: `Error sending forget password email: ${error}`
|
|
65986
66244
|
});
|
|
@@ -66002,7 +66260,7 @@ function useVerificationServiceV2() {
|
|
|
66002
66260
|
async function resendSignUpVerification(email) {
|
|
66003
66261
|
const item = await _getPendingVerificationByEmail(email);
|
|
66004
66262
|
if (!item) {
|
|
66005
|
-
throw new
|
|
66263
|
+
throw new NotFoundError54(
|
|
66006
66264
|
"Pending verification not found."
|
|
66007
66265
|
);
|
|
66008
66266
|
}
|
|
@@ -66056,7 +66314,7 @@ function useVerificationServiceV2() {
|
|
|
66056
66314
|
}
|
|
66057
66315
|
|
|
66058
66316
|
// src/controllers/verification-v2.controller.ts
|
|
66059
|
-
import { BadRequestError as BadRequestError203, logger as
|
|
66317
|
+
import { BadRequestError as BadRequestError203, logger as logger182 } from "@7365admin1/node-server-utils";
|
|
66060
66318
|
import Joi129 from "joi";
|
|
66061
66319
|
function useVerificationControllerV2() {
|
|
66062
66320
|
const {
|
|
@@ -66080,7 +66338,7 @@ function useVerificationControllerV2() {
|
|
|
66080
66338
|
);
|
|
66081
66339
|
if (error) {
|
|
66082
66340
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
66083
|
-
|
|
66341
|
+
logger182.log({ level: "error", message: messages });
|
|
66084
66342
|
next(new BadRequestError203(messages));
|
|
66085
66343
|
return;
|
|
66086
66344
|
}
|
|
@@ -66088,7 +66346,7 @@ function useVerificationControllerV2() {
|
|
|
66088
66346
|
res.json(message);
|
|
66089
66347
|
return;
|
|
66090
66348
|
} catch (error) {
|
|
66091
|
-
|
|
66349
|
+
logger182.log({ level: "error", message: `${error.message}` });
|
|
66092
66350
|
next(error);
|
|
66093
66351
|
return;
|
|
66094
66352
|
}
|
|
@@ -66106,7 +66364,7 @@ function useVerificationControllerV2() {
|
|
|
66106
66364
|
const { error, value } = schema2.validate(req.body, { abortEarly: false });
|
|
66107
66365
|
if (error) {
|
|
66108
66366
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
66109
|
-
|
|
66367
|
+
logger182.log({ level: "error", message: messages });
|
|
66110
66368
|
next(new BadRequestError203(messages));
|
|
66111
66369
|
return;
|
|
66112
66370
|
}
|
|
@@ -66126,7 +66384,7 @@ function useVerificationControllerV2() {
|
|
|
66126
66384
|
res.status(201).json({ message: "Successfully invited user." });
|
|
66127
66385
|
return;
|
|
66128
66386
|
} catch (error2) {
|
|
66129
|
-
|
|
66387
|
+
logger182.log({ level: "error", message: `${error2.message}` });
|
|
66130
66388
|
next(error2);
|
|
66131
66389
|
return;
|
|
66132
66390
|
}
|
|
@@ -66141,7 +66399,7 @@ function useVerificationControllerV2() {
|
|
|
66141
66399
|
const { error, value } = schema2.validate(req.body, { abortEarly: false });
|
|
66142
66400
|
if (error) {
|
|
66143
66401
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
66144
|
-
|
|
66402
|
+
logger182.log({ level: "error", message: messages });
|
|
66145
66403
|
next(new BadRequestError203(messages));
|
|
66146
66404
|
return;
|
|
66147
66405
|
}
|
|
@@ -66155,7 +66413,7 @@ function useVerificationControllerV2() {
|
|
|
66155
66413
|
res.cookie("service-provider-email", value.email, cookieOptions).json({ message: "Successfully invited service provider." });
|
|
66156
66414
|
return;
|
|
66157
66415
|
} catch (error2) {
|
|
66158
|
-
|
|
66416
|
+
logger182.log({ level: "error", message: `controller - ${error2.message}` });
|
|
66159
66417
|
next(error2);
|
|
66160
66418
|
return;
|
|
66161
66419
|
}
|
|
@@ -66173,7 +66431,7 @@ function useVerificationControllerV2() {
|
|
|
66173
66431
|
const { error, value } = schema2.validate(req.body, { abortEarly: false });
|
|
66174
66432
|
if (error) {
|
|
66175
66433
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
66176
|
-
|
|
66434
|
+
logger182.log({ level: "error", message: messages });
|
|
66177
66435
|
next(new BadRequestError203(messages));
|
|
66178
66436
|
return;
|
|
66179
66437
|
}
|
|
@@ -66193,7 +66451,7 @@ function useVerificationControllerV2() {
|
|
|
66193
66451
|
res.status(201).json({ message: "Successfully invited user." });
|
|
66194
66452
|
return;
|
|
66195
66453
|
} catch (error2) {
|
|
66196
|
-
|
|
66454
|
+
logger182.log({ level: "error", message: `${error2.message}` });
|
|
66197
66455
|
next(error2);
|
|
66198
66456
|
return;
|
|
66199
66457
|
}
|
|
@@ -66205,7 +66463,7 @@ function useVerificationControllerV2() {
|
|
|
66205
66463
|
const { error, value } = schema2.validate(req.body, { abortEarly: false });
|
|
66206
66464
|
if (error) {
|
|
66207
66465
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
66208
|
-
|
|
66466
|
+
logger182.log({ level: "error", message: messages });
|
|
66209
66467
|
next(new BadRequestError203(messages));
|
|
66210
66468
|
return;
|
|
66211
66469
|
}
|
|
@@ -66217,7 +66475,7 @@ function useVerificationControllerV2() {
|
|
|
66217
66475
|
});
|
|
66218
66476
|
return;
|
|
66219
66477
|
} catch (error2) {
|
|
66220
|
-
|
|
66478
|
+
logger182.log({ level: "error", message: `${error2.message}` });
|
|
66221
66479
|
next(error2);
|
|
66222
66480
|
return;
|
|
66223
66481
|
}
|
|
@@ -66237,7 +66495,7 @@ function useVerificationControllerV2() {
|
|
|
66237
66495
|
const { error, value } = schema2.validate(req.query);
|
|
66238
66496
|
if (error) {
|
|
66239
66497
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
66240
|
-
|
|
66498
|
+
logger182.log({ level: "error", message: messages });
|
|
66241
66499
|
next(new BadRequestError203(messages));
|
|
66242
66500
|
return;
|
|
66243
66501
|
}
|
|
@@ -66254,7 +66512,7 @@ function useVerificationControllerV2() {
|
|
|
66254
66512
|
res.json(data);
|
|
66255
66513
|
return;
|
|
66256
66514
|
} catch (error2) {
|
|
66257
|
-
|
|
66515
|
+
logger182.log({ level: "error", message: `${error2.message}` });
|
|
66258
66516
|
next(error2);
|
|
66259
66517
|
return;
|
|
66260
66518
|
}
|
|
@@ -66264,7 +66522,7 @@ function useVerificationControllerV2() {
|
|
|
66264
66522
|
const otpId = req.params.id;
|
|
66265
66523
|
const { error } = validation.validate(otpId);
|
|
66266
66524
|
if (error) {
|
|
66267
|
-
|
|
66525
|
+
logger182.log({ level: "error", message: `${error.message}` });
|
|
66268
66526
|
next(new BadRequestError203(error.message));
|
|
66269
66527
|
return;
|
|
66270
66528
|
}
|
|
@@ -66275,7 +66533,7 @@ function useVerificationControllerV2() {
|
|
|
66275
66533
|
});
|
|
66276
66534
|
return;
|
|
66277
66535
|
} catch (error2) {
|
|
66278
|
-
|
|
66536
|
+
logger182.log({ level: "error", message: `${error2.message}` });
|
|
66279
66537
|
next(error2);
|
|
66280
66538
|
return;
|
|
66281
66539
|
}
|
|
@@ -66315,14 +66573,14 @@ function useVerificationControllerV2() {
|
|
|
66315
66573
|
|
|
66316
66574
|
// src/controllers/auth-v2.controller.ts
|
|
66317
66575
|
import Joi130 from "joi";
|
|
66318
|
-
import { BadRequestError as BadRequestError207, logger as
|
|
66576
|
+
import { BadRequestError as BadRequestError207, logger as logger185 } from "@7365admin1/node-server-utils";
|
|
66319
66577
|
|
|
66320
66578
|
// src/services/auth-v2.service.ts
|
|
66321
66579
|
import {
|
|
66322
66580
|
BadRequestError as BadRequestError205,
|
|
66323
66581
|
comparePassword as comparePassword3,
|
|
66324
66582
|
InternalServerError as InternalServerError72,
|
|
66325
|
-
NotFoundError as
|
|
66583
|
+
NotFoundError as NotFoundError56,
|
|
66326
66584
|
useAtlas as useAtlas118,
|
|
66327
66585
|
useCache as useCache68
|
|
66328
66586
|
} from "@7365admin1/node-server-utils";
|
|
@@ -66333,10 +66591,10 @@ import { ObjectId as ObjectId136 } from "mongodb";
|
|
|
66333
66591
|
import {
|
|
66334
66592
|
useAtlas as useAtlas117,
|
|
66335
66593
|
InternalServerError as InternalServerError71,
|
|
66336
|
-
logger as
|
|
66594
|
+
logger as logger183,
|
|
66337
66595
|
BadRequestError as BadRequestError204,
|
|
66338
|
-
paginate as
|
|
66339
|
-
NotFoundError as
|
|
66596
|
+
paginate as paginate61,
|
|
66597
|
+
NotFoundError as NotFoundError55,
|
|
66340
66598
|
AppError as AppError29,
|
|
66341
66599
|
useCache as useCache67,
|
|
66342
66600
|
makeCacheKey as makeCacheKey64,
|
|
@@ -66382,16 +66640,16 @@ function useUserRepoV2() {
|
|
|
66382
66640
|
value = MUser(value);
|
|
66383
66641
|
const res = await collection.insertOne(value, { session });
|
|
66384
66642
|
delNamespace().then(
|
|
66385
|
-
() =>
|
|
66643
|
+
() => logger183.info(`Cache cleared for namespace: ${namespace_collection}`)
|
|
66386
66644
|
).catch(
|
|
66387
|
-
(err) =>
|
|
66645
|
+
(err) => logger183.error(
|
|
66388
66646
|
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
66389
66647
|
err
|
|
66390
66648
|
)
|
|
66391
66649
|
);
|
|
66392
66650
|
return res.insertedId;
|
|
66393
66651
|
} catch (error) {
|
|
66394
|
-
|
|
66652
|
+
logger183.log({ level: "error", message: `${error}` });
|
|
66395
66653
|
if (error.message.includes("duplicate")) {
|
|
66396
66654
|
throw new BadRequestError204("User already exists.");
|
|
66397
66655
|
}
|
|
@@ -66403,14 +66661,14 @@ function useUserRepoV2() {
|
|
|
66403
66661
|
const cacheKey = makeCacheKey64(namespace_collection, { email });
|
|
66404
66662
|
const cachedData = await getCache(cacheKey);
|
|
66405
66663
|
if (cachedData) {
|
|
66406
|
-
|
|
66664
|
+
logger183.info(`Cache hit for key: ${cacheKey}`);
|
|
66407
66665
|
return cachedData;
|
|
66408
66666
|
}
|
|
66409
66667
|
const data = await collection.findOne({
|
|
66410
66668
|
email: { $regex: `^${email}$`, $options: "i" }
|
|
66411
66669
|
});
|
|
66412
|
-
setCache(cacheKey, data, 15 * 60).then(() =>
|
|
66413
|
-
(err) =>
|
|
66670
|
+
setCache(cacheKey, data, 15 * 60).then(() => logger183.info(`Cache set for key: ${cacheKey}`)).catch(
|
|
66671
|
+
(err) => logger183.error(`Failed to set cache for key: ${cacheKey}`, err)
|
|
66414
66672
|
);
|
|
66415
66673
|
return data;
|
|
66416
66674
|
} catch (error) {
|
|
@@ -66425,15 +66683,15 @@ function useUserRepoV2() {
|
|
|
66425
66683
|
});
|
|
66426
66684
|
const cachedData = await getCache(cacheKey);
|
|
66427
66685
|
if (cachedData) {
|
|
66428
|
-
|
|
66686
|
+
logger183.info(`Cache hit for key: ${cacheKey}`);
|
|
66429
66687
|
return cachedData;
|
|
66430
66688
|
}
|
|
66431
66689
|
const data = await collection.findOne({
|
|
66432
66690
|
email: { $regex: `^${email}$`, $options: "i" },
|
|
66433
66691
|
status: "complete" /* COMPLETE */
|
|
66434
66692
|
});
|
|
66435
|
-
setCache(cacheKey, data, 15 * 60).then(() =>
|
|
66436
|
-
(err) =>
|
|
66693
|
+
setCache(cacheKey, data, 15 * 60).then(() => logger183.info(`Cache set for key: ${cacheKey}`)).catch(
|
|
66694
|
+
(err) => logger183.error(`Failed to set cache for key: ${cacheKey}`, err)
|
|
66437
66695
|
);
|
|
66438
66696
|
return data;
|
|
66439
66697
|
} catch (error) {
|
|
@@ -66446,7 +66704,7 @@ function useUserRepoV2() {
|
|
|
66446
66704
|
const cacheKey = makeCacheKey64(namespace_collection, { id });
|
|
66447
66705
|
const cachedData = await getCache(cacheKey);
|
|
66448
66706
|
if (cachedData) {
|
|
66449
|
-
|
|
66707
|
+
logger183.info(`Cache hit for key: ${cacheKey}`);
|
|
66450
66708
|
return cachedData;
|
|
66451
66709
|
}
|
|
66452
66710
|
const results = await collection.aggregate([
|
|
@@ -66469,9 +66727,9 @@ function useUserRepoV2() {
|
|
|
66469
66727
|
]).toArray();
|
|
66470
66728
|
const data = results.length > 0 ? results[0] : null;
|
|
66471
66729
|
if (!data)
|
|
66472
|
-
throw new
|
|
66473
|
-
setCache(cacheKey, data, 15 * 60).then(() =>
|
|
66474
|
-
(err) =>
|
|
66730
|
+
throw new NotFoundError55("User not found.");
|
|
66731
|
+
setCache(cacheKey, data, 15 * 60).then(() => logger183.info(`Cache set for key: ${cacheKey}`)).catch(
|
|
66732
|
+
(err) => logger183.error(`Failed to set cache for key: ${cacheKey}`, err)
|
|
66475
66733
|
);
|
|
66476
66734
|
return data;
|
|
66477
66735
|
} catch (error) {
|
|
@@ -66485,12 +66743,12 @@ function useUserRepoV2() {
|
|
|
66485
66743
|
const cacheKey = makeCacheKey64(namespace_collection, { referralCode });
|
|
66486
66744
|
const cachedData = await getCache(cacheKey);
|
|
66487
66745
|
if (cachedData) {
|
|
66488
|
-
|
|
66746
|
+
logger183.info(`Cache hit for key: ${cacheKey}`);
|
|
66489
66747
|
return cachedData;
|
|
66490
66748
|
}
|
|
66491
66749
|
const data = await collection.findOne({ referralCode });
|
|
66492
|
-
setCache(cacheKey, data, 15 * 60).then(() =>
|
|
66493
|
-
(err) =>
|
|
66750
|
+
setCache(cacheKey, data, 15 * 60).then(() => logger183.info(`Cache set for key: ${cacheKey}`)).catch(
|
|
66751
|
+
(err) => logger183.error(`Failed to set cache for key: ${cacheKey}`, err)
|
|
66494
66752
|
);
|
|
66495
66753
|
return data;
|
|
66496
66754
|
} catch (error) {
|
|
@@ -66502,15 +66760,15 @@ function useUserRepoV2() {
|
|
|
66502
66760
|
const cacheKey = makeCacheKey64(namespace_collection, { email, app });
|
|
66503
66761
|
const cachedData = await getCache(cacheKey);
|
|
66504
66762
|
if (cachedData) {
|
|
66505
|
-
|
|
66763
|
+
logger183.info(`Cache hit for key: ${cacheKey}`);
|
|
66506
66764
|
return cachedData;
|
|
66507
66765
|
}
|
|
66508
66766
|
const data = await collection.findOne({
|
|
66509
66767
|
email,
|
|
66510
66768
|
"roles.app": app
|
|
66511
66769
|
});
|
|
66512
|
-
setCache(cacheKey, data, 15 * 60).then(() =>
|
|
66513
|
-
(err) =>
|
|
66770
|
+
setCache(cacheKey, data, 15 * 60).then(() => logger183.info(`Cache set for key: ${cacheKey}`)).catch(
|
|
66771
|
+
(err) => logger183.error(`Failed to set cache for key: ${cacheKey}`, err)
|
|
66514
66772
|
);
|
|
66515
66773
|
return data;
|
|
66516
66774
|
} catch (error) {
|
|
@@ -66548,9 +66806,9 @@ function useUserRepoV2() {
|
|
|
66548
66806
|
}
|
|
66549
66807
|
}
|
|
66550
66808
|
delNamespace().then(() => {
|
|
66551
|
-
|
|
66809
|
+
logger183.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
66552
66810
|
}).catch((err) => {
|
|
66553
|
-
|
|
66811
|
+
logger183.error(
|
|
66554
66812
|
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
66555
66813
|
err
|
|
66556
66814
|
);
|
|
@@ -66558,7 +66816,7 @@ function useUserRepoV2() {
|
|
|
66558
66816
|
const cacheKey = makeCacheKey64(namespace_collection, cacheOptions);
|
|
66559
66817
|
const cachedData = await getCache(cacheKey);
|
|
66560
66818
|
if (cachedData) {
|
|
66561
|
-
|
|
66819
|
+
logger183.info(`Cache hit for key: ${cacheKey}`);
|
|
66562
66820
|
return cachedData;
|
|
66563
66821
|
}
|
|
66564
66822
|
try {
|
|
@@ -66578,15 +66836,15 @@ function useUserRepoV2() {
|
|
|
66578
66836
|
}
|
|
66579
66837
|
]).toArray();
|
|
66580
66838
|
const length = await collection.countDocuments(query);
|
|
66581
|
-
const data =
|
|
66839
|
+
const data = paginate61(items, page, limit, length);
|
|
66582
66840
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
66583
|
-
|
|
66841
|
+
logger183.info(`Cache set for key: ${cacheKey}`);
|
|
66584
66842
|
}).catch((err) => {
|
|
66585
|
-
|
|
66843
|
+
logger183.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
66586
66844
|
});
|
|
66587
66845
|
return data;
|
|
66588
66846
|
} catch (error) {
|
|
66589
|
-
|
|
66847
|
+
logger183.log({ level: "error", message: `${error}` });
|
|
66590
66848
|
throw error;
|
|
66591
66849
|
}
|
|
66592
66850
|
}
|
|
@@ -66612,9 +66870,9 @@ function useUserRepoV2() {
|
|
|
66612
66870
|
cacheOptions.type = type;
|
|
66613
66871
|
}
|
|
66614
66872
|
delNamespace().then(
|
|
66615
|
-
() =>
|
|
66873
|
+
() => logger183.info(`Cache cleared for namespace: ${namespace_collection}`)
|
|
66616
66874
|
).catch(
|
|
66617
|
-
(err) =>
|
|
66875
|
+
(err) => logger183.error(
|
|
66618
66876
|
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
66619
66877
|
err
|
|
66620
66878
|
)
|
|
@@ -66622,7 +66880,7 @@ function useUserRepoV2() {
|
|
|
66622
66880
|
const cacheKey = makeCacheKey64(namespace_collection, cacheOptions);
|
|
66623
66881
|
const cachedData = await getCache(cacheKey);
|
|
66624
66882
|
if (cachedData) {
|
|
66625
|
-
|
|
66883
|
+
logger183.info(`Cache hit for key: ${cacheKey}`);
|
|
66626
66884
|
return cachedData;
|
|
66627
66885
|
}
|
|
66628
66886
|
try {
|
|
@@ -66634,13 +66892,13 @@ function useUserRepoV2() {
|
|
|
66634
66892
|
{ $project: { _id: 1, name: 1, email: 1, type: 1, status: 1 } }
|
|
66635
66893
|
]).toArray();
|
|
66636
66894
|
const length = await collection.countDocuments(query);
|
|
66637
|
-
const data =
|
|
66638
|
-
setCache(cacheKey, data, 15 * 60).then(() =>
|
|
66639
|
-
(err) =>
|
|
66895
|
+
const data = paginate61(items, page, limit, length);
|
|
66896
|
+
setCache(cacheKey, data, 15 * 60).then(() => logger183.info(`Cache set for key: ${cacheKey}`)).catch(
|
|
66897
|
+
(err) => logger183.error(`Failed to set cache for key: ${cacheKey}`, err)
|
|
66640
66898
|
);
|
|
66641
66899
|
return data;
|
|
66642
66900
|
} catch (error) {
|
|
66643
|
-
|
|
66901
|
+
logger183.log({ level: "error", message: `${error}` });
|
|
66644
66902
|
throw error;
|
|
66645
66903
|
}
|
|
66646
66904
|
}
|
|
@@ -66654,9 +66912,9 @@ function useUserRepoV2() {
|
|
|
66654
66912
|
{ session }
|
|
66655
66913
|
);
|
|
66656
66914
|
delCache(cacheKey).then(() => {
|
|
66657
|
-
|
|
66915
|
+
logger183.info(`Cache deleted for key: ${cacheKey}`);
|
|
66658
66916
|
}).catch((err) => {
|
|
66659
|
-
|
|
66917
|
+
logger183.error(`Failed to delete cache for key: ${cacheKey}`, err);
|
|
66660
66918
|
});
|
|
66661
66919
|
return result;
|
|
66662
66920
|
} catch (error) {
|
|
@@ -66711,9 +66969,9 @@ function useUserRepoV2() {
|
|
|
66711
66969
|
);
|
|
66712
66970
|
const cacheKey = makeCacheKey64(namespace_collection, { _id });
|
|
66713
66971
|
delCache(cacheKey).then(() => {
|
|
66714
|
-
|
|
66972
|
+
logger183.info(`Cache deleted for key: ${cacheKey}`);
|
|
66715
66973
|
}).catch((err) => {
|
|
66716
|
-
|
|
66974
|
+
logger183.error(`Failed to delete cache for key: ${cacheKey}`, err);
|
|
66717
66975
|
});
|
|
66718
66976
|
return `Successfully updated user ${field}.`;
|
|
66719
66977
|
} catch (error) {
|
|
@@ -66746,9 +67004,9 @@ function useUserRepoV2() {
|
|
|
66746
67004
|
);
|
|
66747
67005
|
const cacheKey = makeCacheKey64(namespace_collection, { _id });
|
|
66748
67006
|
delCache(cacheKey).then(() => {
|
|
66749
|
-
|
|
67007
|
+
logger183.info(`Cache deleted for key: ${cacheKey}`);
|
|
66750
67008
|
}).catch((err) => {
|
|
66751
|
-
|
|
67009
|
+
logger183.error(`Failed to delete cache for key: ${cacheKey}`, err);
|
|
66752
67010
|
});
|
|
66753
67011
|
return "Successfully updated user birthday.";
|
|
66754
67012
|
} catch (error) {
|
|
@@ -66769,9 +67027,9 @@ function useUserRepoV2() {
|
|
|
66769
67027
|
);
|
|
66770
67028
|
const cacheKey = makeCacheKey64(namespace_collection, { _id });
|
|
66771
67029
|
delCache(cacheKey).then(() => {
|
|
66772
|
-
|
|
67030
|
+
logger183.info(`Cache deleted for key: ${cacheKey}`);
|
|
66773
67031
|
}).catch((err) => {
|
|
66774
|
-
|
|
67032
|
+
logger183.error(`Failed to delete cache for key: ${cacheKey}`, err);
|
|
66775
67033
|
});
|
|
66776
67034
|
return result;
|
|
66777
67035
|
} catch (error) {
|
|
@@ -66829,7 +67087,7 @@ function useAuthServiceV2() {
|
|
|
66829
67087
|
try {
|
|
66830
67088
|
const user = await getUserByEmail(email);
|
|
66831
67089
|
if (!user) {
|
|
66832
|
-
throw new
|
|
67090
|
+
throw new NotFoundError56(
|
|
66833
67091
|
"Invalid user email. Please check your email and try again."
|
|
66834
67092
|
);
|
|
66835
67093
|
}
|
|
@@ -66959,7 +67217,7 @@ import {
|
|
|
66959
67217
|
comparePassword as comparePassword4,
|
|
66960
67218
|
hashPassword as hashPassword5,
|
|
66961
67219
|
InternalServerError as InternalServerError73,
|
|
66962
|
-
NotFoundError as
|
|
67220
|
+
NotFoundError as NotFoundError57,
|
|
66963
67221
|
useAtlas as useAtlas119,
|
|
66964
67222
|
useS3 as useS33
|
|
66965
67223
|
} from "@7365admin1/node-server-utils";
|
|
@@ -67063,14 +67321,14 @@ function useUserServiceV2() {
|
|
|
67063
67321
|
try {
|
|
67064
67322
|
const otpDoc = await _getVerificationById(id);
|
|
67065
67323
|
if (!otpDoc) {
|
|
67066
|
-
throw new
|
|
67324
|
+
throw new NotFoundError57("You are using an invalid reset link.");
|
|
67067
67325
|
}
|
|
67068
67326
|
if (otpDoc.status === "complete" /* COMPLETE */) {
|
|
67069
67327
|
throw new BadRequestError206("This link has already been invalidated.");
|
|
67070
67328
|
}
|
|
67071
67329
|
const user = await _getUserByEmail(otpDoc.email);
|
|
67072
67330
|
if (!user) {
|
|
67073
|
-
throw new
|
|
67331
|
+
throw new NotFoundError57("User not found.");
|
|
67074
67332
|
}
|
|
67075
67333
|
if (!user._id) {
|
|
67076
67334
|
throw new InternalServerError73("Invalid user ID.");
|
|
@@ -67185,7 +67443,7 @@ function useAuthControllerV2() {
|
|
|
67185
67443
|
});
|
|
67186
67444
|
if (error) {
|
|
67187
67445
|
const messages = error.details.map((d) => d.message);
|
|
67188
|
-
|
|
67446
|
+
logger185.log({ level: "error", message: messages.join(", ") });
|
|
67189
67447
|
next(new BadRequestError207(messages.join(", ")));
|
|
67190
67448
|
return;
|
|
67191
67449
|
}
|
|
@@ -67202,7 +67460,7 @@ function useAuthControllerV2() {
|
|
|
67202
67460
|
return;
|
|
67203
67461
|
} catch (error) {
|
|
67204
67462
|
console.log(error);
|
|
67205
|
-
|
|
67463
|
+
logger185.log({ level: "error", message: error.message });
|
|
67206
67464
|
next(error);
|
|
67207
67465
|
return;
|
|
67208
67466
|
}
|
|
@@ -67220,7 +67478,7 @@ function useAuthControllerV2() {
|
|
|
67220
67478
|
});
|
|
67221
67479
|
if (error) {
|
|
67222
67480
|
const messages = error.details.map((d) => d.message);
|
|
67223
|
-
|
|
67481
|
+
logger185.log({ level: "error", message: messages.join(", ") });
|
|
67224
67482
|
next(new BadRequestError207(messages.join(", ")));
|
|
67225
67483
|
return;
|
|
67226
67484
|
}
|
|
@@ -67233,7 +67491,7 @@ function useAuthControllerV2() {
|
|
|
67233
67491
|
res.cookie("sid", session.sid, cookieOptions).cookie("user", session.user, cookieOptions).json(session);
|
|
67234
67492
|
return;
|
|
67235
67493
|
} catch (error) {
|
|
67236
|
-
|
|
67494
|
+
logger185.log({ level: "error", message: error.message });
|
|
67237
67495
|
next(error);
|
|
67238
67496
|
return;
|
|
67239
67497
|
}
|
|
@@ -67244,7 +67502,7 @@ function useAuthControllerV2() {
|
|
|
67244
67502
|
});
|
|
67245
67503
|
const { error, value } = validation.validate(req.body);
|
|
67246
67504
|
if (error) {
|
|
67247
|
-
|
|
67505
|
+
logger185.log({ level: "error", message: error.message });
|
|
67248
67506
|
next(new BadRequestError207(error.message));
|
|
67249
67507
|
return;
|
|
67250
67508
|
}
|
|
@@ -67253,7 +67511,7 @@ function useAuthControllerV2() {
|
|
|
67253
67511
|
res.json(session);
|
|
67254
67512
|
return;
|
|
67255
67513
|
} catch (error2) {
|
|
67256
|
-
|
|
67514
|
+
logger185.log({ level: "error", message: error2.message });
|
|
67257
67515
|
next(error2);
|
|
67258
67516
|
return;
|
|
67259
67517
|
}
|
|
@@ -67270,7 +67528,7 @@ function useAuthControllerV2() {
|
|
|
67270
67528
|
res.json({ message: "Logged out successfully" });
|
|
67271
67529
|
return;
|
|
67272
67530
|
} catch (error) {
|
|
67273
|
-
|
|
67531
|
+
logger185.log({ level: "error", message: error.message });
|
|
67274
67532
|
next(error);
|
|
67275
67533
|
return;
|
|
67276
67534
|
}
|
|
@@ -67286,7 +67544,7 @@ function useAuthControllerV2() {
|
|
|
67286
67544
|
});
|
|
67287
67545
|
if (error) {
|
|
67288
67546
|
const messages = error.details.map((d) => d.message);
|
|
67289
|
-
|
|
67547
|
+
logger185.log({ level: "error", message: messages.join(", ") });
|
|
67290
67548
|
next(new BadRequestError207(messages.join(", ")));
|
|
67291
67549
|
return;
|
|
67292
67550
|
}
|
|
@@ -67300,7 +67558,7 @@ function useAuthControllerV2() {
|
|
|
67300
67558
|
res.json({ message });
|
|
67301
67559
|
return;
|
|
67302
67560
|
} catch (error2) {
|
|
67303
|
-
|
|
67561
|
+
logger185.log({ level: "error", message: error2.message });
|
|
67304
67562
|
next(error2);
|
|
67305
67563
|
return;
|
|
67306
67564
|
}
|
|
@@ -67316,7 +67574,7 @@ function useAuthControllerV2() {
|
|
|
67316
67574
|
);
|
|
67317
67575
|
if (error) {
|
|
67318
67576
|
const messages = error.details.map((d) => d.message);
|
|
67319
|
-
|
|
67577
|
+
logger185.log({ level: "error", message: messages.join(", ") });
|
|
67320
67578
|
next(new BadRequestError207(messages.join(", ")));
|
|
67321
67579
|
return;
|
|
67322
67580
|
}
|
|
@@ -67326,7 +67584,7 @@ function useAuthControllerV2() {
|
|
|
67326
67584
|
res.json({ message });
|
|
67327
67585
|
return;
|
|
67328
67586
|
} catch (error2) {
|
|
67329
|
-
|
|
67587
|
+
logger185.log({ level: "error", message: error2.message });
|
|
67330
67588
|
next(error2);
|
|
67331
67589
|
return;
|
|
67332
67590
|
}
|
|
@@ -67344,7 +67602,7 @@ function useAuthControllerV2() {
|
|
|
67344
67602
|
// src/controllers/user-v2.controller.ts
|
|
67345
67603
|
import Joi131 from "joi";
|
|
67346
67604
|
import "multer";
|
|
67347
|
-
import { BadRequestError as BadRequestError208, logger as
|
|
67605
|
+
import { BadRequestError as BadRequestError208, logger as logger186 } from "@7365admin1/node-server-utils";
|
|
67348
67606
|
function useUserControllerV2() {
|
|
67349
67607
|
const {
|
|
67350
67608
|
updateBirthday: _updateBirthday,
|
|
@@ -67358,7 +67616,7 @@ function useUserControllerV2() {
|
|
|
67358
67616
|
const { createUserBySignUp, updateUserProfile: _updateUserProfile, updatePasswordById: _updatePasswordById } = useUserServiceV2();
|
|
67359
67617
|
function rejectValidation(error, next) {
|
|
67360
67618
|
const message = error.details.map((d) => d.message).join(", ");
|
|
67361
|
-
|
|
67619
|
+
logger186.log({ level: "error", message });
|
|
67362
67620
|
next(new BadRequestError208(message));
|
|
67363
67621
|
}
|
|
67364
67622
|
async function getById(req, res, next) {
|
|
@@ -67366,7 +67624,7 @@ function useUserControllerV2() {
|
|
|
67366
67624
|
const _id = req.params.id;
|
|
67367
67625
|
const { error, value } = validation.validate(_id);
|
|
67368
67626
|
if (error) {
|
|
67369
|
-
|
|
67627
|
+
logger186.log({ level: "error", message: `${error.message}` });
|
|
67370
67628
|
next(new BadRequestError208(error.message));
|
|
67371
67629
|
return;
|
|
67372
67630
|
}
|
|
@@ -67375,7 +67633,7 @@ function useUserControllerV2() {
|
|
|
67375
67633
|
res.json(user);
|
|
67376
67634
|
return;
|
|
67377
67635
|
} catch (error2) {
|
|
67378
|
-
|
|
67636
|
+
logger186.log({ level: "error", message: `${error2.message}` });
|
|
67379
67637
|
next(error2);
|
|
67380
67638
|
return;
|
|
67381
67639
|
}
|
|
@@ -67389,7 +67647,7 @@ function useUserControllerV2() {
|
|
|
67389
67647
|
res.json(user);
|
|
67390
67648
|
return;
|
|
67391
67649
|
} catch (err) {
|
|
67392
|
-
|
|
67650
|
+
logger186.log({ level: "error", message: `${err.message}` });
|
|
67393
67651
|
next(err);
|
|
67394
67652
|
return;
|
|
67395
67653
|
}
|
|
@@ -67456,7 +67714,7 @@ function useUserControllerV2() {
|
|
|
67456
67714
|
const payload = { ...req.body };
|
|
67457
67715
|
const { error, value } = validation.validate({ id, ...payload });
|
|
67458
67716
|
if (error) {
|
|
67459
|
-
|
|
67717
|
+
logger186.log({ level: "error", message: `${error.message}` });
|
|
67460
67718
|
next(new BadRequestError208(error.message));
|
|
67461
67719
|
return;
|
|
67462
67720
|
}
|
|
@@ -67465,7 +67723,7 @@ function useUserControllerV2() {
|
|
|
67465
67723
|
res.status(201).json({ message: "Successfully created account." });
|
|
67466
67724
|
return;
|
|
67467
67725
|
} catch (error2) {
|
|
67468
|
-
|
|
67726
|
+
logger186.log({ level: "error", message: `${error2.message}` });
|
|
67469
67727
|
next(error2);
|
|
67470
67728
|
return;
|
|
67471
67729
|
}
|
|
@@ -67481,7 +67739,7 @@ function useUserControllerV2() {
|
|
|
67481
67739
|
const payload = { ...req.body };
|
|
67482
67740
|
const { error, value } = validation.validate(payload);
|
|
67483
67741
|
if (error) {
|
|
67484
|
-
|
|
67742
|
+
logger186.log({ level: "error", message: `${error.message}` });
|
|
67485
67743
|
next(new BadRequestError208(error.message));
|
|
67486
67744
|
return;
|
|
67487
67745
|
}
|
|
@@ -67495,7 +67753,7 @@ function useUserControllerV2() {
|
|
|
67495
67753
|
res.json({ message: "Successfully updated profile picture." });
|
|
67496
67754
|
return;
|
|
67497
67755
|
} catch (error2) {
|
|
67498
|
-
|
|
67756
|
+
logger186.log({ level: "error", message: `${error2.message}` });
|
|
67499
67757
|
next(error2);
|
|
67500
67758
|
return;
|
|
67501
67759
|
}
|
|
@@ -67525,7 +67783,7 @@ function useUserControllerV2() {
|
|
|
67525
67783
|
const payload = { ...req.body };
|
|
67526
67784
|
const { error } = validation.validate({ _id, ...payload });
|
|
67527
67785
|
if (error) {
|
|
67528
|
-
|
|
67786
|
+
logger186.log({ level: "error", message: `${error.message}` });
|
|
67529
67787
|
next(new BadRequestError208(error.message));
|
|
67530
67788
|
return;
|
|
67531
67789
|
}
|
|
@@ -67534,7 +67792,7 @@ function useUserControllerV2() {
|
|
|
67534
67792
|
res.json({ message });
|
|
67535
67793
|
return;
|
|
67536
67794
|
} catch (error2) {
|
|
67537
|
-
|
|
67795
|
+
logger186.log({ level: "error", message: `${error2.message}` });
|
|
67538
67796
|
next(error2);
|
|
67539
67797
|
return;
|
|
67540
67798
|
}
|
|
@@ -67556,7 +67814,7 @@ function useUserControllerV2() {
|
|
|
67556
67814
|
const payload = { ...req.body };
|
|
67557
67815
|
const { error } = validation.validate({ _id, ...payload });
|
|
67558
67816
|
if (error) {
|
|
67559
|
-
|
|
67817
|
+
logger186.log({ level: "error", message: `${error.message}` });
|
|
67560
67818
|
next(new BadRequestError208(error.message));
|
|
67561
67819
|
return;
|
|
67562
67820
|
}
|
|
@@ -67565,7 +67823,7 @@ function useUserControllerV2() {
|
|
|
67565
67823
|
res.json({ message });
|
|
67566
67824
|
return;
|
|
67567
67825
|
} catch (error2) {
|
|
67568
|
-
|
|
67826
|
+
logger186.log({ level: "error", message: `${error2.message}` });
|
|
67569
67827
|
next(error2);
|
|
67570
67828
|
return;
|
|
67571
67829
|
}
|
|
@@ -67668,7 +67926,7 @@ import {
|
|
|
67668
67926
|
BadRequestError as BadRequestError210,
|
|
67669
67927
|
InternalServerError as InternalServerError74,
|
|
67670
67928
|
useAtlas as useAtlas120,
|
|
67671
|
-
logger as
|
|
67929
|
+
logger as logger187,
|
|
67672
67930
|
useCache as useCache69
|
|
67673
67931
|
} from "@7365admin1/node-server-utils";
|
|
67674
67932
|
function useRoleRepoV2() {
|
|
@@ -67712,16 +67970,16 @@ function useRoleRepoV2() {
|
|
|
67712
67970
|
try {
|
|
67713
67971
|
const res = await collection.insertOne(value, { session });
|
|
67714
67972
|
delNamespace().then(() => {
|
|
67715
|
-
|
|
67973
|
+
logger187.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
67716
67974
|
}).catch((err) => {
|
|
67717
|
-
|
|
67975
|
+
logger187.error(
|
|
67718
67976
|
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
67719
67977
|
err
|
|
67720
67978
|
);
|
|
67721
67979
|
});
|
|
67722
67980
|
return res.insertedId;
|
|
67723
67981
|
} catch (error) {
|
|
67724
|
-
|
|
67982
|
+
logger187.log({ level: "error", message: `${error}` });
|
|
67725
67983
|
const isDuplicated = error.message.includes("duplicate");
|
|
67726
67984
|
if (isDuplicated) {
|
|
67727
67985
|
throw new BadRequestError210("Role already exists.");
|
|
@@ -67752,7 +68010,7 @@ function useRoleServiceV2() {
|
|
|
67752
68010
|
|
|
67753
68011
|
// src/controllers/role-v2.controller.ts
|
|
67754
68012
|
import Joi132 from "joi";
|
|
67755
|
-
import { BadRequestError as BadRequestError211, logger as
|
|
68013
|
+
import { BadRequestError as BadRequestError211, logger as logger188 } from "@7365admin1/node-server-utils";
|
|
67756
68014
|
function useRoleControllerV2() {
|
|
67757
68015
|
const { createRole: _createRole } = useRoleServiceV2();
|
|
67758
68016
|
async function createRole(req, res, next) {
|
|
@@ -67768,7 +68026,7 @@ function useRoleControllerV2() {
|
|
|
67768
68026
|
const { error, value } = validation.validate(payload, { abortEarly: false });
|
|
67769
68027
|
if (error) {
|
|
67770
68028
|
const message = error.details.map((item) => item.message).join(", ");
|
|
67771
|
-
|
|
68029
|
+
logger188.log({ level: "error", message });
|
|
67772
68030
|
next(new BadRequestError211(message));
|
|
67773
68031
|
return;
|
|
67774
68032
|
}
|
|
@@ -67777,7 +68035,7 @@ function useRoleControllerV2() {
|
|
|
67777
68035
|
res.status(201).json({ message: "Successfully created role.", data: { role } });
|
|
67778
68036
|
return;
|
|
67779
68037
|
} catch (error2) {
|
|
67780
|
-
|
|
68038
|
+
logger188.log({ level: "error", message: error2.message });
|
|
67781
68039
|
next(error2);
|
|
67782
68040
|
return;
|
|
67783
68041
|
}
|
|
@@ -67920,8 +68178,8 @@ function MPost(value) {
|
|
|
67920
68178
|
import {
|
|
67921
68179
|
BadRequestError as BadRequestError212,
|
|
67922
68180
|
InternalServerError as InternalServerError75,
|
|
67923
|
-
NotFoundError as
|
|
67924
|
-
paginate as
|
|
68181
|
+
NotFoundError as NotFoundError58,
|
|
68182
|
+
paginate as paginate62,
|
|
67925
68183
|
useAtlas as useAtlas121
|
|
67926
68184
|
} from "@7365admin1/node-server-utils";
|
|
67927
68185
|
import { ObjectId as ObjectId140 } from "mongodb";
|
|
@@ -68143,7 +68401,7 @@ function usePostPrelovedRepo() {
|
|
|
68143
68401
|
]).toArray();
|
|
68144
68402
|
const data = result[0] ?? null;
|
|
68145
68403
|
if (!data)
|
|
68146
|
-
throw new
|
|
68404
|
+
throw new NotFoundError58("Post not found.");
|
|
68147
68405
|
return data;
|
|
68148
68406
|
} catch (error) {
|
|
68149
68407
|
throw error;
|
|
@@ -68271,7 +68529,7 @@ function usePostPrelovedRepo() {
|
|
|
68271
68529
|
{ session }
|
|
68272
68530
|
).toArray();
|
|
68273
68531
|
const length = await collection.countDocuments(query, { session });
|
|
68274
|
-
return
|
|
68532
|
+
return paginate62(items, page, limit, length);
|
|
68275
68533
|
} catch (error) {
|
|
68276
68534
|
throw error;
|
|
68277
68535
|
}
|
|
@@ -68339,7 +68597,7 @@ function usePostPrelovedRepo() {
|
|
|
68339
68597
|
{ session }
|
|
68340
68598
|
).toArray();
|
|
68341
68599
|
const length = await collection.countDocuments(query, { session });
|
|
68342
|
-
return
|
|
68600
|
+
return paginate62(items, page, limit, length);
|
|
68343
68601
|
} catch (error) {
|
|
68344
68602
|
throw error;
|
|
68345
68603
|
}
|
|
@@ -68423,7 +68681,7 @@ function usePostPrelovedRepo() {
|
|
|
68423
68681
|
}
|
|
68424
68682
|
|
|
68425
68683
|
// src/controllers/post-preloved.controller.ts
|
|
68426
|
-
import { BadRequestError as BadRequestError214, logger as
|
|
68684
|
+
import { BadRequestError as BadRequestError214, logger as logger189 } from "@7365admin1/node-server-utils";
|
|
68427
68685
|
import Joi136 from "joi";
|
|
68428
68686
|
|
|
68429
68687
|
// src/services/post-preloved.service.ts
|
|
@@ -68433,7 +68691,7 @@ import { useAtlas as useAtlas123 } from "@7365admin1/node-server-utils";
|
|
|
68433
68691
|
import {
|
|
68434
68692
|
BadRequestError as BadRequestError213,
|
|
68435
68693
|
InternalServerError as InternalServerError76,
|
|
68436
|
-
NotFoundError as
|
|
68694
|
+
NotFoundError as NotFoundError59,
|
|
68437
68695
|
useAtlas as useAtlas122
|
|
68438
68696
|
} from "@7365admin1/node-server-utils";
|
|
68439
68697
|
import { ObjectId as ObjectId142 } from "mongodb";
|
|
@@ -68529,7 +68787,7 @@ function usePostFavoriteRepo() {
|
|
|
68529
68787
|
}
|
|
68530
68788
|
const result = await collection.findOne({ _id });
|
|
68531
68789
|
if (!result)
|
|
68532
|
-
throw new
|
|
68790
|
+
throw new NotFoundError59("Favorite not found.");
|
|
68533
68791
|
return result;
|
|
68534
68792
|
}
|
|
68535
68793
|
async function getByPostId(postId) {
|
|
@@ -68540,7 +68798,7 @@ function usePostFavoriteRepo() {
|
|
|
68540
68798
|
}
|
|
68541
68799
|
const result = await collection.findOne({ postId });
|
|
68542
68800
|
if (!result)
|
|
68543
|
-
throw new
|
|
68801
|
+
throw new NotFoundError59("Favorite not found.");
|
|
68544
68802
|
return result;
|
|
68545
68803
|
}
|
|
68546
68804
|
async function updateById(_id, userId, session) {
|
|
@@ -68652,7 +68910,7 @@ function usePostPrelovedController() {
|
|
|
68652
68910
|
});
|
|
68653
68911
|
if (error) {
|
|
68654
68912
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68655
|
-
|
|
68913
|
+
logger189.log({ level: "error", message: messages });
|
|
68656
68914
|
next(new BadRequestError214(messages));
|
|
68657
68915
|
return;
|
|
68658
68916
|
}
|
|
@@ -68661,7 +68919,7 @@ function usePostPrelovedController() {
|
|
|
68661
68919
|
res.status(201).json(data);
|
|
68662
68920
|
return;
|
|
68663
68921
|
} catch (error2) {
|
|
68664
|
-
|
|
68922
|
+
logger189.log({ level: "error", message: error2.message });
|
|
68665
68923
|
next(error2);
|
|
68666
68924
|
return;
|
|
68667
68925
|
}
|
|
@@ -68676,7 +68934,7 @@ function usePostPrelovedController() {
|
|
|
68676
68934
|
userId: req.query.userId
|
|
68677
68935
|
});
|
|
68678
68936
|
if (error) {
|
|
68679
|
-
|
|
68937
|
+
logger189.log({ level: "error", message: error.message });
|
|
68680
68938
|
next(new BadRequestError214(error.message));
|
|
68681
68939
|
return;
|
|
68682
68940
|
}
|
|
@@ -68685,7 +68943,7 @@ function usePostPrelovedController() {
|
|
|
68685
68943
|
res.status(200).json(data);
|
|
68686
68944
|
return;
|
|
68687
68945
|
} catch (error2) {
|
|
68688
|
-
|
|
68946
|
+
logger189.log({ level: "error", message: error2.message });
|
|
68689
68947
|
next(error2);
|
|
68690
68948
|
return;
|
|
68691
68949
|
}
|
|
@@ -68710,7 +68968,7 @@ function usePostPrelovedController() {
|
|
|
68710
68968
|
});
|
|
68711
68969
|
if (error) {
|
|
68712
68970
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68713
|
-
|
|
68971
|
+
logger189.log({ level: "error", message: messages });
|
|
68714
68972
|
next(new BadRequestError214(messages));
|
|
68715
68973
|
return;
|
|
68716
68974
|
}
|
|
@@ -68740,7 +68998,7 @@ function usePostPrelovedController() {
|
|
|
68740
68998
|
res.status(200).json(data);
|
|
68741
68999
|
return;
|
|
68742
69000
|
} catch (error2) {
|
|
68743
|
-
|
|
69001
|
+
logger189.log({ level: "error", message: error2.message });
|
|
68744
69002
|
next(error2);
|
|
68745
69003
|
return;
|
|
68746
69004
|
}
|
|
@@ -68765,7 +69023,7 @@ function usePostPrelovedController() {
|
|
|
68765
69023
|
);
|
|
68766
69024
|
if (error) {
|
|
68767
69025
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68768
|
-
|
|
69026
|
+
logger189.log({ level: "error", message: messages });
|
|
68769
69027
|
next(new BadRequestError214(messages));
|
|
68770
69028
|
return;
|
|
68771
69029
|
}
|
|
@@ -68783,7 +69041,7 @@ function usePostPrelovedController() {
|
|
|
68783
69041
|
res.status(200).json(data);
|
|
68784
69042
|
return;
|
|
68785
69043
|
} catch (error2) {
|
|
68786
|
-
|
|
69044
|
+
logger189.log({ level: "error", message: error2.message });
|
|
68787
69045
|
next(error2);
|
|
68788
69046
|
return;
|
|
68789
69047
|
}
|
|
@@ -68796,7 +69054,7 @@ function usePostPrelovedController() {
|
|
|
68796
69054
|
});
|
|
68797
69055
|
if (error) {
|
|
68798
69056
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68799
|
-
|
|
69057
|
+
logger189.log({ level: "error", message: messages });
|
|
68800
69058
|
next(new BadRequestError214(messages));
|
|
68801
69059
|
return;
|
|
68802
69060
|
}
|
|
@@ -68805,7 +69063,7 @@ function usePostPrelovedController() {
|
|
|
68805
69063
|
res.status(200).json(data);
|
|
68806
69064
|
return;
|
|
68807
69065
|
} catch (error2) {
|
|
68808
|
-
|
|
69066
|
+
logger189.log({ level: "error", message: error2.message });
|
|
68809
69067
|
next(error2);
|
|
68810
69068
|
return;
|
|
68811
69069
|
}
|
|
@@ -68816,7 +69074,7 @@ function usePostPrelovedController() {
|
|
|
68816
69074
|
});
|
|
68817
69075
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
68818
69076
|
if (error) {
|
|
68819
|
-
|
|
69077
|
+
logger189.log({ level: "error", message: error.message });
|
|
68820
69078
|
next(new BadRequestError214(error.message));
|
|
68821
69079
|
return;
|
|
68822
69080
|
}
|
|
@@ -68825,7 +69083,7 @@ function usePostPrelovedController() {
|
|
|
68825
69083
|
res.status(200).json({ message: "Successfully deleted post." });
|
|
68826
69084
|
return;
|
|
68827
69085
|
} catch (error2) {
|
|
68828
|
-
|
|
69086
|
+
logger189.log({ level: "error", message: error2.message });
|
|
68829
69087
|
next(error2);
|
|
68830
69088
|
return;
|
|
68831
69089
|
}
|
|
@@ -68840,7 +69098,7 @@ function usePostPrelovedController() {
|
|
|
68840
69098
|
status: req.body.status
|
|
68841
69099
|
});
|
|
68842
69100
|
if (error) {
|
|
68843
|
-
|
|
69101
|
+
logger189.log({ level: "error", message: error.message });
|
|
68844
69102
|
next(new BadRequestError214(error.message));
|
|
68845
69103
|
return;
|
|
68846
69104
|
}
|
|
@@ -68849,7 +69107,7 @@ function usePostPrelovedController() {
|
|
|
68849
69107
|
res.status(200).json(data);
|
|
68850
69108
|
return;
|
|
68851
69109
|
} catch (error2) {
|
|
68852
|
-
|
|
69110
|
+
logger189.log({ level: "error", message: error2.message });
|
|
68853
69111
|
next(error2);
|
|
68854
69112
|
return;
|
|
68855
69113
|
}
|
|
@@ -68904,7 +69162,7 @@ function usePostFavoriteService2() {
|
|
|
68904
69162
|
}
|
|
68905
69163
|
|
|
68906
69164
|
// src/controllers/post-favorite.controller.ts
|
|
68907
|
-
import { BadRequestError as BadRequestError215, logger as
|
|
69165
|
+
import { BadRequestError as BadRequestError215, logger as logger190 } from "@7365admin1/node-server-utils";
|
|
68908
69166
|
import Joi137 from "joi";
|
|
68909
69167
|
function usePostFavoriteController() {
|
|
68910
69168
|
const { addFavorite: _addFavorite, toggleFavorite: _toggleFavorite } = usePostFavoriteService2();
|
|
@@ -68915,7 +69173,7 @@ function usePostFavoriteController() {
|
|
|
68915
69173
|
});
|
|
68916
69174
|
if (error) {
|
|
68917
69175
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68918
|
-
|
|
69176
|
+
logger190.log({ level: "error", message: messages });
|
|
68919
69177
|
next(new BadRequestError215(messages));
|
|
68920
69178
|
return;
|
|
68921
69179
|
}
|
|
@@ -68924,7 +69182,7 @@ function usePostFavoriteController() {
|
|
|
68924
69182
|
res.status(201).json(data);
|
|
68925
69183
|
return;
|
|
68926
69184
|
} catch (error2) {
|
|
68927
|
-
|
|
69185
|
+
logger190.log({ level: "error", message: error2.message });
|
|
68928
69186
|
next(error2);
|
|
68929
69187
|
return;
|
|
68930
69188
|
}
|
|
@@ -68935,7 +69193,7 @@ function usePostFavoriteController() {
|
|
|
68935
69193
|
});
|
|
68936
69194
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
68937
69195
|
if (error) {
|
|
68938
|
-
|
|
69196
|
+
logger190.log({ level: "error", message: error.message });
|
|
68939
69197
|
next(new BadRequestError215(error.message));
|
|
68940
69198
|
return;
|
|
68941
69199
|
}
|
|
@@ -68944,7 +69202,7 @@ function usePostFavoriteController() {
|
|
|
68944
69202
|
res.status(200).json(data);
|
|
68945
69203
|
return;
|
|
68946
69204
|
} catch (error2) {
|
|
68947
|
-
|
|
69205
|
+
logger190.log({ level: "error", message: error2.message });
|
|
68948
69206
|
next(error2);
|
|
68949
69207
|
return;
|
|
68950
69208
|
}
|
|
@@ -68955,7 +69213,7 @@ function usePostFavoriteController() {
|
|
|
68955
69213
|
});
|
|
68956
69214
|
const { error, value } = schema2.validate({ postId: req.params.postId });
|
|
68957
69215
|
if (error) {
|
|
68958
|
-
|
|
69216
|
+
logger190.log({ level: "error", message: error.message });
|
|
68959
69217
|
next(new BadRequestError215(error.message));
|
|
68960
69218
|
return;
|
|
68961
69219
|
}
|
|
@@ -68964,7 +69222,7 @@ function usePostFavoriteController() {
|
|
|
68964
69222
|
res.status(200).json(data);
|
|
68965
69223
|
return;
|
|
68966
69224
|
} catch (error2) {
|
|
68967
|
-
|
|
69225
|
+
logger190.log({ level: "error", message: error2.message });
|
|
68968
69226
|
next(error2);
|
|
68969
69227
|
return;
|
|
68970
69228
|
}
|
|
@@ -68983,7 +69241,7 @@ function usePostFavoriteController() {
|
|
|
68983
69241
|
const { error: bodyError, value: bodyValue } = schemaUpdatePostFavorite.validate(req.body, { abortEarly: false });
|
|
68984
69242
|
if (bodyError) {
|
|
68985
69243
|
const messages = bodyError.details.map((d) => d.message).join(", ");
|
|
68986
|
-
|
|
69244
|
+
logger190.log({ level: "error", message: messages });
|
|
68987
69245
|
next(new BadRequestError215(messages));
|
|
68988
69246
|
return;
|
|
68989
69247
|
}
|
|
@@ -68991,7 +69249,7 @@ function usePostFavoriteController() {
|
|
|
68991
69249
|
const data = await _toggleFavorite(paramsValue._id, bodyValue.userId);
|
|
68992
69250
|
res.status(200).json(data);
|
|
68993
69251
|
} catch (error) {
|
|
68994
|
-
|
|
69252
|
+
logger190.log({ level: "error", message: error.message });
|
|
68995
69253
|
next(error);
|
|
68996
69254
|
}
|
|
68997
69255
|
}
|
|
@@ -69047,7 +69305,7 @@ function MCategoryPreloved(value) {
|
|
|
69047
69305
|
import {
|
|
69048
69306
|
BadRequestError as BadRequestError216,
|
|
69049
69307
|
InternalServerError as InternalServerError77,
|
|
69050
|
-
NotFoundError as
|
|
69308
|
+
NotFoundError as NotFoundError60,
|
|
69051
69309
|
useAtlas as useAtlas125
|
|
69052
69310
|
} from "@7365admin1/node-server-utils";
|
|
69053
69311
|
import { ObjectId as ObjectId145 } from "mongodb";
|
|
@@ -69090,7 +69348,7 @@ function useCategoryPrelovedRepo() {
|
|
|
69090
69348
|
try {
|
|
69091
69349
|
const data = await collection.findOne({ _id: objectId2 });
|
|
69092
69350
|
if (!data) {
|
|
69093
|
-
throw new
|
|
69351
|
+
throw new NotFoundError60("Category not found.");
|
|
69094
69352
|
}
|
|
69095
69353
|
return data;
|
|
69096
69354
|
} catch (error) {
|
|
@@ -69119,7 +69377,7 @@ function useCategoryPrelovedRepo() {
|
|
|
69119
69377
|
}
|
|
69120
69378
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
69121
69379
|
if (!existing)
|
|
69122
|
-
throw new
|
|
69380
|
+
throw new NotFoundError60("Category not found.");
|
|
69123
69381
|
const res = await collection.updateOne(
|
|
69124
69382
|
{ _id: objectId2 },
|
|
69125
69383
|
{ $set: { ...value, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
@@ -69137,7 +69395,7 @@ function useCategoryPrelovedRepo() {
|
|
|
69137
69395
|
}
|
|
69138
69396
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
69139
69397
|
if (!existing)
|
|
69140
|
-
throw new
|
|
69398
|
+
throw new NotFoundError60("Category not found.");
|
|
69141
69399
|
const res = await collection.deleteOne({ _id: objectId2 });
|
|
69142
69400
|
if (res.deletedCount === 0)
|
|
69143
69401
|
throw new InternalServerError77("Unable to delete category.");
|
|
@@ -69147,7 +69405,7 @@ function useCategoryPrelovedRepo() {
|
|
|
69147
69405
|
}
|
|
69148
69406
|
|
|
69149
69407
|
// src/controllers/category-preloved.controller.ts
|
|
69150
|
-
import { BadRequestError as BadRequestError217, logger as
|
|
69408
|
+
import { BadRequestError as BadRequestError217, logger as logger191 } from "@7365admin1/node-server-utils";
|
|
69151
69409
|
import Joi139 from "joi";
|
|
69152
69410
|
function useCategoryPrelovedController() {
|
|
69153
69411
|
const { getAll: _getAll, getById: _getById, addCategory: _addCategory, updateById: _updateById, deleteById: _deleteById } = useCategoryPrelovedRepo();
|
|
@@ -69159,7 +69417,7 @@ function useCategoryPrelovedController() {
|
|
|
69159
69417
|
const { error, value } = schema2.validate(req.query, { abortEarly: false });
|
|
69160
69418
|
if (error) {
|
|
69161
69419
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
69162
|
-
|
|
69420
|
+
logger191.log({ level: "error", message: messages });
|
|
69163
69421
|
next(new BadRequestError217(messages));
|
|
69164
69422
|
return;
|
|
69165
69423
|
}
|
|
@@ -69168,7 +69426,7 @@ function useCategoryPrelovedController() {
|
|
|
69168
69426
|
res.status(200).json({ data });
|
|
69169
69427
|
return;
|
|
69170
69428
|
} catch (error2) {
|
|
69171
|
-
|
|
69429
|
+
logger191.log({ level: "error", message: error2.message });
|
|
69172
69430
|
next(error2);
|
|
69173
69431
|
return;
|
|
69174
69432
|
}
|
|
@@ -69179,7 +69437,7 @@ function useCategoryPrelovedController() {
|
|
|
69179
69437
|
});
|
|
69180
69438
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
69181
69439
|
if (error) {
|
|
69182
|
-
|
|
69440
|
+
logger191.log({ level: "error", message: error.message });
|
|
69183
69441
|
next(new BadRequestError217(error.message));
|
|
69184
69442
|
return;
|
|
69185
69443
|
}
|
|
@@ -69188,7 +69446,7 @@ function useCategoryPrelovedController() {
|
|
|
69188
69446
|
res.status(200).json({ data });
|
|
69189
69447
|
return;
|
|
69190
69448
|
} catch (error2) {
|
|
69191
|
-
|
|
69449
|
+
logger191.log({ level: "error", message: error2.message });
|
|
69192
69450
|
next(error2);
|
|
69193
69451
|
return;
|
|
69194
69452
|
}
|
|
@@ -69199,7 +69457,7 @@ function useCategoryPrelovedController() {
|
|
|
69199
69457
|
});
|
|
69200
69458
|
if (error) {
|
|
69201
69459
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
69202
|
-
|
|
69460
|
+
logger191.log({ level: "error", message: messages });
|
|
69203
69461
|
next(new BadRequestError217(messages));
|
|
69204
69462
|
return;
|
|
69205
69463
|
}
|
|
@@ -69207,7 +69465,7 @@ function useCategoryPrelovedController() {
|
|
|
69207
69465
|
const data = await _addCategory(value);
|
|
69208
69466
|
res.status(201).json(data);
|
|
69209
69467
|
} catch (error2) {
|
|
69210
|
-
|
|
69468
|
+
logger191.log({ level: "error", message: error2.message });
|
|
69211
69469
|
next(error2);
|
|
69212
69470
|
}
|
|
69213
69471
|
}
|
|
@@ -69217,7 +69475,7 @@ function useCategoryPrelovedController() {
|
|
|
69217
69475
|
});
|
|
69218
69476
|
if (error) {
|
|
69219
69477
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
69220
|
-
|
|
69478
|
+
logger191.log({ level: "error", message: messages });
|
|
69221
69479
|
next(new BadRequestError217(messages));
|
|
69222
69480
|
return;
|
|
69223
69481
|
}
|
|
@@ -69225,7 +69483,7 @@ function useCategoryPrelovedController() {
|
|
|
69225
69483
|
const data = await _updateById(req.params.id, value);
|
|
69226
69484
|
res.status(200).json(data);
|
|
69227
69485
|
} catch (error2) {
|
|
69228
|
-
|
|
69486
|
+
logger191.log({ level: "error", message: error2.message });
|
|
69229
69487
|
next(error2);
|
|
69230
69488
|
}
|
|
69231
69489
|
}
|
|
@@ -69235,7 +69493,7 @@ function useCategoryPrelovedController() {
|
|
|
69235
69493
|
});
|
|
69236
69494
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
69237
69495
|
if (error) {
|
|
69238
|
-
|
|
69496
|
+
logger191.log({ level: "error", message: error.message });
|
|
69239
69497
|
next(new BadRequestError217(error.message));
|
|
69240
69498
|
return;
|
|
69241
69499
|
}
|
|
@@ -69243,7 +69501,7 @@ function useCategoryPrelovedController() {
|
|
|
69243
69501
|
const data = await _deleteById(value._id);
|
|
69244
69502
|
res.status(200).json(data);
|
|
69245
69503
|
} catch (error2) {
|
|
69246
|
-
|
|
69504
|
+
logger191.log({ level: "error", message: error2.message });
|
|
69247
69505
|
next(error2);
|
|
69248
69506
|
}
|
|
69249
69507
|
}
|
|
@@ -69304,7 +69562,7 @@ function MSubcategoryPreloved(value) {
|
|
|
69304
69562
|
import {
|
|
69305
69563
|
BadRequestError as BadRequestError218,
|
|
69306
69564
|
InternalServerError as InternalServerError78,
|
|
69307
|
-
NotFoundError as
|
|
69565
|
+
NotFoundError as NotFoundError61,
|
|
69308
69566
|
useAtlas as useAtlas126
|
|
69309
69567
|
} from "@7365admin1/node-server-utils";
|
|
69310
69568
|
import { ObjectId as ObjectId147 } from "mongodb";
|
|
@@ -69355,7 +69613,7 @@ function useSubcategoryPrelovedRepo() {
|
|
|
69355
69613
|
try {
|
|
69356
69614
|
const data = await collection.findOne({ _id: objectId2 });
|
|
69357
69615
|
if (!data) {
|
|
69358
|
-
throw new
|
|
69616
|
+
throw new NotFoundError61("Subcategory not found.");
|
|
69359
69617
|
}
|
|
69360
69618
|
return data;
|
|
69361
69619
|
} catch (error) {
|
|
@@ -69421,7 +69679,7 @@ function useSubcategoryPrelovedRepo() {
|
|
|
69421
69679
|
}
|
|
69422
69680
|
|
|
69423
69681
|
// src/controllers/subcategory-preloved.controller.ts
|
|
69424
|
-
import { BadRequestError as BadRequestError219, logger as
|
|
69682
|
+
import { BadRequestError as BadRequestError219, logger as logger192 } from "@7365admin1/node-server-utils";
|
|
69425
69683
|
import Joi141 from "joi";
|
|
69426
69684
|
function useSubcategoryPrelovedController() {
|
|
69427
69685
|
const {
|
|
@@ -69440,7 +69698,7 @@ function useSubcategoryPrelovedController() {
|
|
|
69440
69698
|
const { error, value } = schema2.validate(req.query, { abortEarly: false });
|
|
69441
69699
|
if (error) {
|
|
69442
69700
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
69443
|
-
|
|
69701
|
+
logger192.log({ level: "error", message: messages });
|
|
69444
69702
|
next(new BadRequestError219(messages));
|
|
69445
69703
|
return;
|
|
69446
69704
|
}
|
|
@@ -69449,7 +69707,7 @@ function useSubcategoryPrelovedController() {
|
|
|
69449
69707
|
res.status(200).json({ data });
|
|
69450
69708
|
return;
|
|
69451
69709
|
} catch (error2) {
|
|
69452
|
-
|
|
69710
|
+
logger192.log({ level: "error", message: error2.message });
|
|
69453
69711
|
next(error2);
|
|
69454
69712
|
return;
|
|
69455
69713
|
}
|
|
@@ -69460,7 +69718,7 @@ function useSubcategoryPrelovedController() {
|
|
|
69460
69718
|
});
|
|
69461
69719
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
69462
69720
|
if (error) {
|
|
69463
|
-
|
|
69721
|
+
logger192.log({ level: "error", message: error.message });
|
|
69464
69722
|
next(new BadRequestError219(error.message));
|
|
69465
69723
|
return;
|
|
69466
69724
|
}
|
|
@@ -69469,7 +69727,7 @@ function useSubcategoryPrelovedController() {
|
|
|
69469
69727
|
res.status(200).json({ data });
|
|
69470
69728
|
return;
|
|
69471
69729
|
} catch (error2) {
|
|
69472
|
-
|
|
69730
|
+
logger192.log({ level: "error", message: error2.message });
|
|
69473
69731
|
next(error2);
|
|
69474
69732
|
return;
|
|
69475
69733
|
}
|
|
@@ -69480,7 +69738,7 @@ function useSubcategoryPrelovedController() {
|
|
|
69480
69738
|
});
|
|
69481
69739
|
if (error) {
|
|
69482
69740
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
69483
|
-
|
|
69741
|
+
logger192.log({ level: "error", message: messages });
|
|
69484
69742
|
next(new BadRequestError219(messages));
|
|
69485
69743
|
return;
|
|
69486
69744
|
}
|
|
@@ -69488,7 +69746,7 @@ function useSubcategoryPrelovedController() {
|
|
|
69488
69746
|
const data = await _addSubcategory(value);
|
|
69489
69747
|
res.status(201).json(data);
|
|
69490
69748
|
} catch (error2) {
|
|
69491
|
-
|
|
69749
|
+
logger192.log({ level: "error", message: error2.message });
|
|
69492
69750
|
next(error2);
|
|
69493
69751
|
}
|
|
69494
69752
|
}
|
|
@@ -69506,7 +69764,7 @@ function useSubcategoryPrelovedController() {
|
|
|
69506
69764
|
const { error: bodyError, value: bodyValue } = schemaUpdateSubcategoryPreloved.validate(req.body, { abortEarly: false });
|
|
69507
69765
|
if (bodyError) {
|
|
69508
69766
|
const messages = bodyError.details.map((d) => d.message).join(", ");
|
|
69509
|
-
|
|
69767
|
+
logger192.log({ level: "error", message: messages });
|
|
69510
69768
|
next(new BadRequestError219(messages));
|
|
69511
69769
|
return;
|
|
69512
69770
|
}
|
|
@@ -69514,7 +69772,7 @@ function useSubcategoryPrelovedController() {
|
|
|
69514
69772
|
const data = await _updateById(paramsValue._id, bodyValue);
|
|
69515
69773
|
res.status(200).json(data);
|
|
69516
69774
|
} catch (error) {
|
|
69517
|
-
|
|
69775
|
+
logger192.log({ level: "error", message: error.message });
|
|
69518
69776
|
next(error);
|
|
69519
69777
|
}
|
|
69520
69778
|
}
|
|
@@ -69531,7 +69789,7 @@ function useSubcategoryPrelovedController() {
|
|
|
69531
69789
|
const data = await _deleteById(value._id);
|
|
69532
69790
|
res.status(200).json(data);
|
|
69533
69791
|
} catch (error2) {
|
|
69534
|
-
|
|
69792
|
+
logger192.log({ level: "error", message: error2.message });
|
|
69535
69793
|
next(error2);
|
|
69536
69794
|
}
|
|
69537
69795
|
}
|
|
@@ -69630,7 +69888,7 @@ function MChatPreloved(value) {
|
|
|
69630
69888
|
import {
|
|
69631
69889
|
BadRequestError as BadRequestError220,
|
|
69632
69890
|
InternalServerError as InternalServerError79,
|
|
69633
|
-
NotFoundError as
|
|
69891
|
+
NotFoundError as NotFoundError62,
|
|
69634
69892
|
useAtlas as useAtlas127
|
|
69635
69893
|
} from "@7365admin1/node-server-utils";
|
|
69636
69894
|
import { ObjectId as ObjectId149 } from "mongodb";
|
|
@@ -69670,7 +69928,7 @@ function useChatPrelovedRepo() {
|
|
|
69670
69928
|
}
|
|
69671
69929
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
69672
69930
|
if (!existing)
|
|
69673
|
-
throw new
|
|
69931
|
+
throw new NotFoundError62("Chat not found.");
|
|
69674
69932
|
value.edited = true;
|
|
69675
69933
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
69676
69934
|
const res = await collection.updateOne({ _id: objectId2 }, { $set: value });
|
|
@@ -69687,7 +69945,7 @@ function useChatPrelovedRepo() {
|
|
|
69687
69945
|
}
|
|
69688
69946
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
69689
69947
|
if (!existing)
|
|
69690
|
-
throw new
|
|
69948
|
+
throw new NotFoundError62("Chat not found.");
|
|
69691
69949
|
const res = await collection.updateOne(
|
|
69692
69950
|
{ _id: objectId2 },
|
|
69693
69951
|
{ $set: { deletedAt: (/* @__PURE__ */ new Date()).toISOString(), updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
@@ -69705,7 +69963,7 @@ import { BadRequestError as BadRequestError221, InternalServerError as InternalS
|
|
|
69705
69963
|
// src/repositories/channel-preloved.repo.ts
|
|
69706
69964
|
import {
|
|
69707
69965
|
InternalServerError as InternalServerError80,
|
|
69708
|
-
paginate as
|
|
69966
|
+
paginate as paginate64,
|
|
69709
69967
|
useAtlas as useAtlas128
|
|
69710
69968
|
} from "@7365admin1/node-server-utils";
|
|
69711
69969
|
import { ObjectId as ObjectId151 } from "mongodb";
|
|
@@ -69864,7 +70122,7 @@ function useChannelPrelovedRepo() {
|
|
|
69864
70122
|
const totalCount = result[0].totalCount[0]?.count ?? 0;
|
|
69865
70123
|
const items = result[0].items;
|
|
69866
70124
|
items.reverse();
|
|
69867
|
-
return
|
|
70125
|
+
return paginate64(items, normalizedPage, normalizedLimit, totalCount);
|
|
69868
70126
|
} catch (error) {
|
|
69869
70127
|
throw error;
|
|
69870
70128
|
}
|
|
@@ -69987,7 +70245,7 @@ function useChannelPrelovedRepo() {
|
|
|
69987
70245
|
const result = await collection.aggregate(pipeline).toArray();
|
|
69988
70246
|
const totalCount = result[0].totalCount[0]?.count ?? 0;
|
|
69989
70247
|
const items = result[0].items;
|
|
69990
|
-
return
|
|
70248
|
+
return paginate64(items, normalizedPage, normalizedLimit, totalCount);
|
|
69991
70249
|
} catch (error) {
|
|
69992
70250
|
throw error;
|
|
69993
70251
|
}
|
|
@@ -70052,7 +70310,7 @@ function useChatPrelovedService() {
|
|
|
70052
70310
|
}
|
|
70053
70311
|
|
|
70054
70312
|
// src/controllers/chat-preloved.controller.ts
|
|
70055
|
-
import { BadRequestError as BadRequestError222, logger as
|
|
70313
|
+
import { BadRequestError as BadRequestError222, logger as logger193 } from "@7365admin1/node-server-utils";
|
|
70056
70314
|
import Joi144 from "joi";
|
|
70057
70315
|
function useChatPrelovedController() {
|
|
70058
70316
|
const { add: _add } = useChatPrelovedService();
|
|
@@ -70063,7 +70321,7 @@ function useChatPrelovedController() {
|
|
|
70063
70321
|
});
|
|
70064
70322
|
if (error) {
|
|
70065
70323
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
70066
|
-
|
|
70324
|
+
logger193.log({ level: "error", message: messages });
|
|
70067
70325
|
next(new BadRequestError222(messages));
|
|
70068
70326
|
return;
|
|
70069
70327
|
}
|
|
@@ -70071,7 +70329,7 @@ function useChatPrelovedController() {
|
|
|
70071
70329
|
const data = await _add(value);
|
|
70072
70330
|
res.status(201).json(data);
|
|
70073
70331
|
} catch (error2) {
|
|
70074
|
-
|
|
70332
|
+
logger193.log({ level: "error", message: error2.message });
|
|
70075
70333
|
next(error2);
|
|
70076
70334
|
}
|
|
70077
70335
|
}
|
|
@@ -70081,7 +70339,7 @@ function useChatPrelovedController() {
|
|
|
70081
70339
|
});
|
|
70082
70340
|
if (error) {
|
|
70083
70341
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
70084
|
-
|
|
70342
|
+
logger193.log({ level: "error", message: messages });
|
|
70085
70343
|
next(new BadRequestError222(messages));
|
|
70086
70344
|
return;
|
|
70087
70345
|
}
|
|
@@ -70089,7 +70347,7 @@ function useChatPrelovedController() {
|
|
|
70089
70347
|
const data = await _updateById(req.params.id, value);
|
|
70090
70348
|
res.status(200).json(data);
|
|
70091
70349
|
} catch (error2) {
|
|
70092
|
-
|
|
70350
|
+
logger193.log({ level: "error", message: error2.message });
|
|
70093
70351
|
next(error2);
|
|
70094
70352
|
}
|
|
70095
70353
|
}
|
|
@@ -70099,7 +70357,7 @@ function useChatPrelovedController() {
|
|
|
70099
70357
|
});
|
|
70100
70358
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
70101
70359
|
if (error) {
|
|
70102
|
-
|
|
70360
|
+
logger193.log({ level: "error", message: error.message });
|
|
70103
70361
|
next(new BadRequestError222(error.message));
|
|
70104
70362
|
return;
|
|
70105
70363
|
}
|
|
@@ -70107,7 +70365,7 @@ function useChatPrelovedController() {
|
|
|
70107
70365
|
const data = await _deleteById(value._id);
|
|
70108
70366
|
res.status(200).json(data);
|
|
70109
70367
|
} catch (error2) {
|
|
70110
|
-
|
|
70368
|
+
logger193.log({ level: "error", message: error2.message });
|
|
70111
70369
|
next(error2);
|
|
70112
70370
|
}
|
|
70113
70371
|
}
|
|
@@ -70116,7 +70374,7 @@ function useChatPrelovedController() {
|
|
|
70116
70374
|
|
|
70117
70375
|
// src/events/chat-preloved.event.ts
|
|
70118
70376
|
import Joi145 from "joi";
|
|
70119
|
-
import { logger as
|
|
70377
|
+
import { logger as logger194, useCache as useCache70 } from "@7365admin1/node-server-utils";
|
|
70120
70378
|
function parseSid(cookieHeader) {
|
|
70121
70379
|
const match = cookieHeader.match(/(?:^|;\s*)sid=([^;]*)/);
|
|
70122
70380
|
return match ? decodeURIComponent(match[1]) : null;
|
|
@@ -70169,7 +70427,7 @@ function chatPrelovedEvents(io) {
|
|
|
70169
70427
|
socket.data.userId = (session._id ?? sessionData).toString();
|
|
70170
70428
|
next();
|
|
70171
70429
|
} catch (error) {
|
|
70172
|
-
|
|
70430
|
+
logger194.log({ level: "error", message: `Socket auth error: ${error.message}` });
|
|
70173
70431
|
next(new Error("Authentication error"));
|
|
70174
70432
|
}
|
|
70175
70433
|
});
|
|
@@ -70218,7 +70476,7 @@ function chatPrelovedEvents(io) {
|
|
|
70218
70476
|
}
|
|
70219
70477
|
|
|
70220
70478
|
// src/controllers/channel-preloved.controller.ts
|
|
70221
|
-
import { BadRequestError as BadRequestError223, logger as
|
|
70479
|
+
import { BadRequestError as BadRequestError223, logger as logger195 } from "@7365admin1/node-server-utils";
|
|
70222
70480
|
import Joi146 from "joi";
|
|
70223
70481
|
function useChannelPrelovedController() {
|
|
70224
70482
|
const {
|
|
@@ -70233,7 +70491,7 @@ function useChannelPrelovedController() {
|
|
|
70233
70491
|
});
|
|
70234
70492
|
if (error) {
|
|
70235
70493
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
70236
|
-
|
|
70494
|
+
logger195.log({ level: "error", message: messages });
|
|
70237
70495
|
next(new BadRequestError223(messages));
|
|
70238
70496
|
return;
|
|
70239
70497
|
}
|
|
@@ -70241,7 +70499,7 @@ function useChannelPrelovedController() {
|
|
|
70241
70499
|
const data = await _add(value);
|
|
70242
70500
|
res.status(201).json(data);
|
|
70243
70501
|
} catch (error2) {
|
|
70244
|
-
|
|
70502
|
+
logger195.log({ level: "error", message: error2.message });
|
|
70245
70503
|
next(error2);
|
|
70246
70504
|
}
|
|
70247
70505
|
}
|
|
@@ -70259,13 +70517,13 @@ function useChannelPrelovedController() {
|
|
|
70259
70517
|
req.params
|
|
70260
70518
|
);
|
|
70261
70519
|
if (paramError) {
|
|
70262
|
-
|
|
70520
|
+
logger195.log({ level: "error", message: paramError.message });
|
|
70263
70521
|
next(new BadRequestError223(paramError.message));
|
|
70264
70522
|
return;
|
|
70265
70523
|
}
|
|
70266
70524
|
const { error: queryError, value: query } = querySchema.validate(req.query);
|
|
70267
70525
|
if (queryError) {
|
|
70268
|
-
|
|
70526
|
+
logger195.log({ level: "error", message: queryError.message });
|
|
70269
70527
|
next(new BadRequestError223(queryError.message));
|
|
70270
70528
|
return;
|
|
70271
70529
|
}
|
|
@@ -70279,7 +70537,7 @@ function useChannelPrelovedController() {
|
|
|
70279
70537
|
);
|
|
70280
70538
|
res.status(200).json(data);
|
|
70281
70539
|
} catch (error) {
|
|
70282
|
-
|
|
70540
|
+
logger195.log({ level: "error", message: error.message });
|
|
70283
70541
|
next(error);
|
|
70284
70542
|
}
|
|
70285
70543
|
}
|
|
@@ -70291,7 +70549,7 @@ function useChannelPrelovedController() {
|
|
|
70291
70549
|
});
|
|
70292
70550
|
const { error, value } = querySchema.validate(req.query);
|
|
70293
70551
|
if (error) {
|
|
70294
|
-
|
|
70552
|
+
logger195.log({ level: "error", message: error.message });
|
|
70295
70553
|
next(new BadRequestError223(error.message));
|
|
70296
70554
|
return;
|
|
70297
70555
|
}
|
|
@@ -70303,7 +70561,7 @@ function useChannelPrelovedController() {
|
|
|
70303
70561
|
);
|
|
70304
70562
|
res.status(200).json(data);
|
|
70305
70563
|
} catch (error2) {
|
|
70306
|
-
|
|
70564
|
+
logger195.log({ level: "error", message: error2.message });
|
|
70307
70565
|
next(error2);
|
|
70308
70566
|
}
|
|
70309
70567
|
}
|
|
@@ -70316,7 +70574,7 @@ function useChannelPrelovedController() {
|
|
|
70316
70574
|
});
|
|
70317
70575
|
const { error, value } = querySchema.validate(req.query);
|
|
70318
70576
|
if (error) {
|
|
70319
|
-
|
|
70577
|
+
logger195.log({ level: "error", message: error.message });
|
|
70320
70578
|
next(new BadRequestError223(error.message));
|
|
70321
70579
|
return;
|
|
70322
70580
|
}
|
|
@@ -70329,7 +70587,7 @@ function useChannelPrelovedController() {
|
|
|
70329
70587
|
);
|
|
70330
70588
|
res.status(200).json(data);
|
|
70331
70589
|
} catch (error2) {
|
|
70332
|
-
|
|
70590
|
+
logger195.log({ level: "error", message: error2.message });
|
|
70333
70591
|
next(error2);
|
|
70334
70592
|
}
|
|
70335
70593
|
}
|
|
@@ -70339,7 +70597,7 @@ function useChannelPrelovedController() {
|
|
|
70339
70597
|
// src/repositories/bid-preloved.repo.ts
|
|
70340
70598
|
import {
|
|
70341
70599
|
InternalServerError as InternalServerError82,
|
|
70342
|
-
NotFoundError as
|
|
70600
|
+
NotFoundError as NotFoundError63,
|
|
70343
70601
|
useAtlas as useAtlas130
|
|
70344
70602
|
} from "@7365admin1/node-server-utils";
|
|
70345
70603
|
import { ObjectId as ObjectId152 } from "mongodb";
|
|
@@ -70361,7 +70619,7 @@ function useBidPrelovedRepo() {
|
|
|
70361
70619
|
const objectId2 = typeof _id === "string" ? new ObjectId152(_id) : _id;
|
|
70362
70620
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
70363
70621
|
if (!existing)
|
|
70364
|
-
throw new
|
|
70622
|
+
throw new NotFoundError63("Bid not found.");
|
|
70365
70623
|
const res = await collection.updateOne(
|
|
70366
70624
|
{ _id: objectId2 },
|
|
70367
70625
|
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
@@ -70375,7 +70633,7 @@ function useBidPrelovedRepo() {
|
|
|
70375
70633
|
_id = new ObjectId152(_id);
|
|
70376
70634
|
const result = await collection.findOne({ _id });
|
|
70377
70635
|
if (!result)
|
|
70378
|
-
throw new
|
|
70636
|
+
throw new NotFoundError63("Bid not found.");
|
|
70379
70637
|
return result;
|
|
70380
70638
|
}
|
|
70381
70639
|
return { add, getById, updateStatus };
|
|
@@ -70449,7 +70707,7 @@ function useBidPrelovedService() {
|
|
|
70449
70707
|
}
|
|
70450
70708
|
|
|
70451
70709
|
// src/controllers/bid-preloved.controller.ts
|
|
70452
|
-
import { BadRequestError as BadRequestError224, logger as
|
|
70710
|
+
import { BadRequestError as BadRequestError224, logger as logger196 } from "@7365admin1/node-server-utils";
|
|
70453
70711
|
import Joi147 from "joi";
|
|
70454
70712
|
function useBidPrelovedController() {
|
|
70455
70713
|
const { createBid: _createBid } = useBidPrelovedService();
|
|
@@ -70460,7 +70718,7 @@ function useBidPrelovedController() {
|
|
|
70460
70718
|
});
|
|
70461
70719
|
if (error) {
|
|
70462
70720
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
70463
|
-
|
|
70721
|
+
logger196.log({ level: "error", message: messages });
|
|
70464
70722
|
next(new BadRequestError224(messages));
|
|
70465
70723
|
return;
|
|
70466
70724
|
}
|
|
@@ -70469,7 +70727,7 @@ function useBidPrelovedController() {
|
|
|
70469
70727
|
res.status(201).json(data);
|
|
70470
70728
|
} catch (error2) {
|
|
70471
70729
|
console.log("error", error2);
|
|
70472
|
-
|
|
70730
|
+
logger196.log({ level: "error", message: error2.message });
|
|
70473
70731
|
next(error2);
|
|
70474
70732
|
}
|
|
70475
70733
|
}
|
|
@@ -70481,7 +70739,7 @@ function useBidPrelovedController() {
|
|
|
70481
70739
|
req.params
|
|
70482
70740
|
);
|
|
70483
70741
|
if (paramError) {
|
|
70484
|
-
|
|
70742
|
+
logger196.log({ level: "error", message: paramError.message });
|
|
70485
70743
|
next(new BadRequestError224(paramError.message));
|
|
70486
70744
|
return;
|
|
70487
70745
|
}
|
|
@@ -70489,7 +70747,7 @@ function useBidPrelovedController() {
|
|
|
70489
70747
|
req.body
|
|
70490
70748
|
);
|
|
70491
70749
|
if (bodyError) {
|
|
70492
|
-
|
|
70750
|
+
logger196.log({ level: "error", message: bodyError.message });
|
|
70493
70751
|
next(new BadRequestError224(bodyError.message));
|
|
70494
70752
|
return;
|
|
70495
70753
|
}
|
|
@@ -70497,7 +70755,7 @@ function useBidPrelovedController() {
|
|
|
70497
70755
|
const data = await _updateStatus(params.id, body.status);
|
|
70498
70756
|
res.status(200).json(data);
|
|
70499
70757
|
} catch (error) {
|
|
70500
|
-
|
|
70758
|
+
logger196.log({ level: "error", message: error.message });
|
|
70501
70759
|
next(error);
|
|
70502
70760
|
}
|
|
70503
70761
|
}
|
|
@@ -70507,7 +70765,7 @@ function useBidPrelovedController() {
|
|
|
70507
70765
|
});
|
|
70508
70766
|
const { error, value: params } = paramsSchema.validate(req.params);
|
|
70509
70767
|
if (error) {
|
|
70510
|
-
|
|
70768
|
+
logger196.log({ level: "error", message: error.message });
|
|
70511
70769
|
next(new BadRequestError224(error.message));
|
|
70512
70770
|
return;
|
|
70513
70771
|
}
|
|
@@ -70515,7 +70773,7 @@ function useBidPrelovedController() {
|
|
|
70515
70773
|
const data = await _getById(params.id);
|
|
70516
70774
|
res.status(200).json(data);
|
|
70517
70775
|
} catch (error2) {
|
|
70518
|
-
|
|
70776
|
+
logger196.log({ level: "error", message: error2.message });
|
|
70519
70777
|
next(error2);
|
|
70520
70778
|
}
|
|
70521
70779
|
}
|
|
@@ -70654,8 +70912,8 @@ var residentFormEntry = Joi148.object({
|
|
|
70654
70912
|
import {
|
|
70655
70913
|
BadRequestError as BadRequestError225,
|
|
70656
70914
|
InternalServerError as InternalServerError84,
|
|
70657
|
-
NotFoundError as
|
|
70658
|
-
paginate as
|
|
70915
|
+
NotFoundError as NotFoundError64,
|
|
70916
|
+
paginate as paginate65,
|
|
70659
70917
|
useAtlas as useAtlas132,
|
|
70660
70918
|
useCache as useCache71
|
|
70661
70919
|
} from "@7365admin1/node-server-utils";
|
|
@@ -70743,7 +71001,7 @@ function useFormEntryRepo() {
|
|
|
70743
71001
|
{ $project: { user: 0 } }
|
|
70744
71002
|
]).toArray();
|
|
70745
71003
|
const length = await collection.countDocuments(query);
|
|
70746
|
-
const data =
|
|
71004
|
+
const data = paginate65(items, page, limit, length);
|
|
70747
71005
|
return data;
|
|
70748
71006
|
} catch (error) {
|
|
70749
71007
|
throw error;
|
|
@@ -70759,7 +71017,7 @@ function useFormEntryRepo() {
|
|
|
70759
71017
|
try {
|
|
70760
71018
|
const [data] = await collection.aggregate([{ $match: query }]).toArray();
|
|
70761
71019
|
if (!data) {
|
|
70762
|
-
throw new
|
|
71020
|
+
throw new NotFoundError64("Document not found.");
|
|
70763
71021
|
}
|
|
70764
71022
|
return data;
|
|
70765
71023
|
} catch (error) {
|
|
@@ -70783,11 +71041,11 @@ function useFormEntryRepo() {
|
|
|
70783
71041
|
}
|
|
70784
71042
|
const onlineFormRequest = await collection.findOne({ _id });
|
|
70785
71043
|
if (!onlineFormRequest) {
|
|
70786
|
-
throw new
|
|
71044
|
+
throw new NotFoundError64("Online form not found.");
|
|
70787
71045
|
}
|
|
70788
71046
|
const user = await getUserById(onlineFormRequest.userId.toString());
|
|
70789
71047
|
if (!user || !user._id) {
|
|
70790
|
-
throw new
|
|
71048
|
+
throw new NotFoundError64("User not found.");
|
|
70791
71049
|
}
|
|
70792
71050
|
const userId = user._id.toString();
|
|
70793
71051
|
await NotificationService.onlineFormRequestStatusUpdated({
|
|
@@ -70874,7 +71132,7 @@ function useFormEntryRepo() {
|
|
|
70874
71132
|
{ $limit: limit }
|
|
70875
71133
|
]).toArray();
|
|
70876
71134
|
const length = await collection.countDocuments(query);
|
|
70877
|
-
const data =
|
|
71135
|
+
const data = paginate65(items, page, limit, length);
|
|
70878
71136
|
return data;
|
|
70879
71137
|
} catch (error) {
|
|
70880
71138
|
throw error;
|
|
@@ -70893,7 +71151,7 @@ function useFormEntryRepo() {
|
|
|
70893
71151
|
}
|
|
70894
71152
|
|
|
70895
71153
|
// src/controllers/online-forms-v2.controller.ts
|
|
70896
|
-
import { BadRequestError as BadRequestError226, logger as
|
|
71154
|
+
import { BadRequestError as BadRequestError226, logger as logger198 } from "@7365admin1/node-server-utils";
|
|
70897
71155
|
import Joi149 from "joi";
|
|
70898
71156
|
import ExcelJS3 from "exceljs";
|
|
70899
71157
|
import fs6 from "fs";
|
|
@@ -70955,7 +71213,7 @@ function useFormEntryController() {
|
|
|
70955
71213
|
});
|
|
70956
71214
|
if (error) {
|
|
70957
71215
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
70958
|
-
|
|
71216
|
+
logger198.log({ level: "error", message: messages });
|
|
70959
71217
|
next(new BadRequestError226(messages));
|
|
70960
71218
|
return;
|
|
70961
71219
|
}
|
|
@@ -70964,7 +71222,7 @@ function useFormEntryController() {
|
|
|
70964
71222
|
fs6.unlink(req.file.path, () => {
|
|
70965
71223
|
});
|
|
70966
71224
|
} catch (error) {
|
|
70967
|
-
|
|
71225
|
+
logger198.log({ level: "error", message: error.message });
|
|
70968
71226
|
next(error);
|
|
70969
71227
|
}
|
|
70970
71228
|
}
|
|
@@ -70981,7 +71239,7 @@ function useFormEntryController() {
|
|
|
70981
71239
|
const { error, value } = schema2.validate(req.query);
|
|
70982
71240
|
if (error) {
|
|
70983
71241
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
70984
|
-
|
|
71242
|
+
logger198.log({ level: "error", message: messages });
|
|
70985
71243
|
next(new BadRequestError226(messages));
|
|
70986
71244
|
return;
|
|
70987
71245
|
}
|
|
@@ -70990,7 +71248,7 @@ function useFormEntryController() {
|
|
|
70990
71248
|
res.json(data);
|
|
70991
71249
|
return;
|
|
70992
71250
|
} catch (error) {
|
|
70993
|
-
|
|
71251
|
+
logger198.log({ level: "error", message: error.message });
|
|
70994
71252
|
next(error);
|
|
70995
71253
|
return;
|
|
70996
71254
|
}
|
|
@@ -71003,7 +71261,7 @@ function useFormEntryController() {
|
|
|
71003
71261
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
71004
71262
|
if (error) {
|
|
71005
71263
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
71006
|
-
|
|
71264
|
+
logger198.log({ level: "error", message: messages });
|
|
71007
71265
|
next(new BadRequestError226(messages));
|
|
71008
71266
|
return;
|
|
71009
71267
|
}
|
|
@@ -71012,7 +71270,7 @@ function useFormEntryController() {
|
|
|
71012
71270
|
res.json(data);
|
|
71013
71271
|
return;
|
|
71014
71272
|
} catch (error) {
|
|
71015
|
-
|
|
71273
|
+
logger198.log({ level: "error", message: error.message });
|
|
71016
71274
|
next(error);
|
|
71017
71275
|
return;
|
|
71018
71276
|
}
|
|
@@ -71025,7 +71283,7 @@ function useFormEntryController() {
|
|
|
71025
71283
|
});
|
|
71026
71284
|
if (error) {
|
|
71027
71285
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
71028
|
-
|
|
71286
|
+
logger198.log({ level: "error", message: messages });
|
|
71029
71287
|
next(new BadRequestError226(messages));
|
|
71030
71288
|
return;
|
|
71031
71289
|
}
|
|
@@ -71034,7 +71292,7 @@ function useFormEntryController() {
|
|
|
71034
71292
|
res.json({ message: "Successfully updated online form." });
|
|
71035
71293
|
return;
|
|
71036
71294
|
} catch (error) {
|
|
71037
|
-
|
|
71295
|
+
logger198.log({ level: "error", message: error.message });
|
|
71038
71296
|
next(error);
|
|
71039
71297
|
return;
|
|
71040
71298
|
}
|
|
@@ -71045,7 +71303,7 @@ function useFormEntryController() {
|
|
|
71045
71303
|
const _id = req.params.id;
|
|
71046
71304
|
const { error } = validation.validate(_id);
|
|
71047
71305
|
if (error) {
|
|
71048
|
-
|
|
71306
|
+
logger198.log({ level: "error", message: error.message });
|
|
71049
71307
|
next(new BadRequestError226(error.message));
|
|
71050
71308
|
return;
|
|
71051
71309
|
}
|
|
@@ -71053,7 +71311,7 @@ function useFormEntryController() {
|
|
|
71053
71311
|
res.json({ message: "Successfully deleted online form." });
|
|
71054
71312
|
return;
|
|
71055
71313
|
} catch (error) {
|
|
71056
|
-
|
|
71314
|
+
logger198.log({ level: "error", message: error.message });
|
|
71057
71315
|
next(error);
|
|
71058
71316
|
return;
|
|
71059
71317
|
}
|
|
@@ -71070,7 +71328,7 @@ function useFormEntryController() {
|
|
|
71070
71328
|
});
|
|
71071
71329
|
if (error) {
|
|
71072
71330
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
71073
|
-
|
|
71331
|
+
logger198.log({ level: "error", message: messages });
|
|
71074
71332
|
next(new BadRequestError226(messages));
|
|
71075
71333
|
return;
|
|
71076
71334
|
}
|
|
@@ -71079,7 +71337,7 @@ function useFormEntryController() {
|
|
|
71079
71337
|
res.status(201).json({ message: data });
|
|
71080
71338
|
return;
|
|
71081
71339
|
} catch (error2) {
|
|
71082
|
-
|
|
71340
|
+
logger198.log({ level: "error", message: error2.message });
|
|
71083
71341
|
next(error2);
|
|
71084
71342
|
return;
|
|
71085
71343
|
}
|
|
@@ -71091,7 +71349,7 @@ function useFormEntryController() {
|
|
|
71091
71349
|
});
|
|
71092
71350
|
if (error) {
|
|
71093
71351
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
71094
|
-
|
|
71352
|
+
logger198.log({ level: "error", message: messages });
|
|
71095
71353
|
next(new BadRequestError226(messages));
|
|
71096
71354
|
return;
|
|
71097
71355
|
}
|
|
@@ -71100,7 +71358,7 @@ function useFormEntryController() {
|
|
|
71100
71358
|
res.status(201).json({ message: data });
|
|
71101
71359
|
return;
|
|
71102
71360
|
} catch (error2) {
|
|
71103
|
-
|
|
71361
|
+
logger198.log({ level: "error", message: error2.message });
|
|
71104
71362
|
next(error2);
|
|
71105
71363
|
return;
|
|
71106
71364
|
}
|
|
@@ -71120,7 +71378,7 @@ function useFormEntryController() {
|
|
|
71120
71378
|
});
|
|
71121
71379
|
if (error) {
|
|
71122
71380
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
71123
|
-
|
|
71381
|
+
logger198.log({ level: "error", message: messages });
|
|
71124
71382
|
next(new BadRequestError226(messages));
|
|
71125
71383
|
return;
|
|
71126
71384
|
}
|
|
@@ -71128,7 +71386,7 @@ function useFormEntryController() {
|
|
|
71128
71386
|
const result = await _residentForm({ userId, site, org, search, page, limit });
|
|
71129
71387
|
res.json(result);
|
|
71130
71388
|
} catch (error) {
|
|
71131
|
-
|
|
71389
|
+
logger198.log({ level: "error", message: error.message });
|
|
71132
71390
|
next(error);
|
|
71133
71391
|
return;
|
|
71134
71392
|
}
|
|
@@ -71184,7 +71442,7 @@ function useBuildingLevelService() {
|
|
|
71184
71442
|
}
|
|
71185
71443
|
|
|
71186
71444
|
// src/controllers/building-level.controller.ts
|
|
71187
|
-
import { BadRequestError as BadRequestError227, logger as
|
|
71445
|
+
import { BadRequestError as BadRequestError227, logger as logger199 } from "@7365admin1/node-server-utils";
|
|
71188
71446
|
import Joi150 from "joi";
|
|
71189
71447
|
function useBuildingLevelController() {
|
|
71190
71448
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
|
|
@@ -71202,7 +71460,7 @@ function useBuildingLevelController() {
|
|
|
71202
71460
|
});
|
|
71203
71461
|
if (error) {
|
|
71204
71462
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
71205
|
-
|
|
71463
|
+
logger199.log({ level: "error", message: messages });
|
|
71206
71464
|
next(new BadRequestError227(messages));
|
|
71207
71465
|
return;
|
|
71208
71466
|
}
|
|
@@ -71226,7 +71484,7 @@ function useBuildingLevelController() {
|
|
|
71226
71484
|
});
|
|
71227
71485
|
if (error) {
|
|
71228
71486
|
const messages = error.details.map((d) => d.message);
|
|
71229
|
-
|
|
71487
|
+
logger199.log({ level: "error", message: messages.join(", ") });
|
|
71230
71488
|
next(new BadRequestError227(messages.join(", ")));
|
|
71231
71489
|
return;
|
|
71232
71490
|
}
|
|
@@ -71252,7 +71510,7 @@ function useBuildingLevelController() {
|
|
|
71252
71510
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
71253
71511
|
if (error) {
|
|
71254
71512
|
const messages = error.details.map((d) => d.message);
|
|
71255
|
-
|
|
71513
|
+
logger199.log({ level: "error", message: messages.join(", ") });
|
|
71256
71514
|
next(new BadRequestError227(messages.join(", ")));
|
|
71257
71515
|
return;
|
|
71258
71516
|
}
|
|
@@ -71272,7 +71530,7 @@ function useBuildingLevelController() {
|
|
|
71272
71530
|
});
|
|
71273
71531
|
if (error) {
|
|
71274
71532
|
const messages = error.details.map((d) => d.message);
|
|
71275
|
-
|
|
71533
|
+
logger199.log({ level: "error", message: messages.join(", ") });
|
|
71276
71534
|
next(new BadRequestError227(messages.join(", ")));
|
|
71277
71535
|
return;
|
|
71278
71536
|
}
|
|
@@ -71291,7 +71549,7 @@ function useBuildingLevelController() {
|
|
|
71291
71549
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
71292
71550
|
if (error) {
|
|
71293
71551
|
const messages = error.details.map((d) => d.message);
|
|
71294
|
-
|
|
71552
|
+
logger199.log({ level: "error", message: messages.join(", ") });
|
|
71295
71553
|
next(new BadRequestError227(messages.join(", ")));
|
|
71296
71554
|
return;
|
|
71297
71555
|
}
|
|
@@ -71316,7 +71574,7 @@ function useBuildingLevelController() {
|
|
|
71316
71574
|
const { error, value } = schema2.validate(req.body);
|
|
71317
71575
|
if (error) {
|
|
71318
71576
|
const messages = error.details.map((d) => d.message);
|
|
71319
|
-
|
|
71577
|
+
logger199.log({ level: "error", message: messages.join(", ") });
|
|
71320
71578
|
next(new BadRequestError227(messages.join(", ")));
|
|
71321
71579
|
return;
|
|
71322
71580
|
}
|
|
@@ -71342,7 +71600,7 @@ function useBuildingLevelController() {
|
|
|
71342
71600
|
});
|
|
71343
71601
|
if (error) {
|
|
71344
71602
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
71345
|
-
|
|
71603
|
+
logger199.log({ level: "error", message: messages });
|
|
71346
71604
|
next(new BadRequestError227(messages));
|
|
71347
71605
|
return;
|
|
71348
71606
|
}
|
|
@@ -71366,7 +71624,7 @@ function useBuildingLevelController() {
|
|
|
71366
71624
|
}
|
|
71367
71625
|
|
|
71368
71626
|
// src/models/hid-amico.model.ts
|
|
71369
|
-
import { BadRequestError as BadRequestError228, logger as
|
|
71627
|
+
import { BadRequestError as BadRequestError228, logger as logger200 } from "@7365admin1/node-server-utils";
|
|
71370
71628
|
import { ObjectId as ObjectId155 } from "mongodb";
|
|
71371
71629
|
import Joi151 from "joi";
|
|
71372
71630
|
function canReadObjectId(value) {
|
|
@@ -71581,7 +71839,7 @@ var schemaHidAmicoNotificationParams = Joi151.object({
|
|
|
71581
71839
|
function MHidAmicoReader(value) {
|
|
71582
71840
|
const { error } = schemaHidAmicoReader.validate(value);
|
|
71583
71841
|
if (error) {
|
|
71584
|
-
|
|
71842
|
+
logger200.info(`HID Amico reader: ${error.message}`);
|
|
71585
71843
|
throw new BadRequestError228(error.message);
|
|
71586
71844
|
}
|
|
71587
71845
|
return {
|
|
@@ -71608,7 +71866,7 @@ function MHidAmicoReader(value) {
|
|
|
71608
71866
|
function MHidAmicoEvent(value) {
|
|
71609
71867
|
const { error } = schemaHidAmicoEvent.validate(value);
|
|
71610
71868
|
if (error) {
|
|
71611
|
-
|
|
71869
|
+
logger200.info(`HID Amico event: ${error.message}`);
|
|
71612
71870
|
throw new BadRequestError228(error.message);
|
|
71613
71871
|
}
|
|
71614
71872
|
return {
|
|
@@ -71627,7 +71885,7 @@ function optionalObjectId(value) {
|
|
|
71627
71885
|
function MHidAmicoIdentity(value) {
|
|
71628
71886
|
const { error } = schemaHidAmicoIdentity.validate(value);
|
|
71629
71887
|
if (error) {
|
|
71630
|
-
|
|
71888
|
+
logger200.info(`HID Amico identity: ${error.message}`);
|
|
71631
71889
|
throw new BadRequestError228(error.message);
|
|
71632
71890
|
}
|
|
71633
71891
|
return {
|
|
@@ -71654,8 +71912,8 @@ function MHidAmicoIdentity(value) {
|
|
|
71654
71912
|
import {
|
|
71655
71913
|
BadRequestError as BadRequestError229,
|
|
71656
71914
|
InternalServerError as InternalServerError85,
|
|
71657
|
-
logger as
|
|
71658
|
-
paginate as
|
|
71915
|
+
logger as logger201,
|
|
71916
|
+
paginate as paginate66,
|
|
71659
71917
|
useAtlas as useAtlas134
|
|
71660
71918
|
} from "@7365admin1/node-server-utils";
|
|
71661
71919
|
import { ObjectId as ObjectId156 } from "mongodb";
|
|
@@ -71731,7 +71989,7 @@ function useHidAmicoRepo() {
|
|
|
71731
71989
|
]);
|
|
71732
71990
|
return "HID Amico indexes created.";
|
|
71733
71991
|
} catch (error) {
|
|
71734
|
-
|
|
71992
|
+
logger201.error(error.message);
|
|
71735
71993
|
throw new Error("Failed to create HID Amico indexes.");
|
|
71736
71994
|
}
|
|
71737
71995
|
}
|
|
@@ -71756,7 +72014,7 @@ function useHidAmicoRepo() {
|
|
|
71756
72014
|
}
|
|
71757
72015
|
const items = await readers().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
|
|
71758
72016
|
const total = await readers().countDocuments(query);
|
|
71759
|
-
return
|
|
72017
|
+
return paginate66(items.map(hideSecret), page, limit, total);
|
|
71760
72018
|
}
|
|
71761
72019
|
async function getById(id, options = {}) {
|
|
71762
72020
|
const _id = toId(id, "reader ID");
|
|
@@ -71819,7 +72077,7 @@ function useHidAmicoRepo() {
|
|
|
71819
72077
|
}
|
|
71820
72078
|
const items = await events().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
|
|
71821
72079
|
const total = await events().countDocuments(query);
|
|
71822
|
-
return
|
|
72080
|
+
return paginate66(items, page, limit, total);
|
|
71823
72081
|
}
|
|
71824
72082
|
async function addIdentity(value, session) {
|
|
71825
72083
|
try {
|
|
@@ -71865,7 +72123,7 @@ function useHidAmicoRepo() {
|
|
|
71865
72123
|
}
|
|
71866
72124
|
const items = await identities().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
|
|
71867
72125
|
const total = await identities().countDocuments(query);
|
|
71868
|
-
return
|
|
72126
|
+
return paginate66(items, page, limit, total);
|
|
71869
72127
|
}
|
|
71870
72128
|
async function updateIdentity(id, value, session) {
|
|
71871
72129
|
const { error } = schemaUpdateHidAmicoIdentity.validate(value);
|