@aurispec/core-backend 1.0.4 → 1.0.6

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.
Files changed (106) hide show
  1. package/dist/database/migrations/1772984882048-modified_reviews_table.d.ts +7 -0
  2. package/dist/database/migrations/1772984882048-modified_reviews_table.d.ts.map +1 -0
  3. package/dist/database/migrations/1772984882048-modified_reviews_table.js +61 -0
  4. package/dist/database/migrations/1773052871526-modified_categories_table.d.ts +7 -0
  5. package/dist/database/migrations/1773052871526-modified_categories_table.d.ts.map +1 -0
  6. package/dist/database/migrations/1773052871526-modified_categories_table.js +19 -0
  7. package/dist/models/BusinessModel.d.ts +2 -0
  8. package/dist/models/BusinessModel.d.ts.map +1 -1
  9. package/dist/models/BusinessModel.js +9 -0
  10. package/dist/models/CategoryModel.d.ts +2 -0
  11. package/dist/models/CategoryModel.d.ts.map +1 -1
  12. package/dist/models/CategoryModel.js +10 -0
  13. package/dist/models/ReviewModel.d.ts +5 -0
  14. package/dist/models/ReviewModel.d.ts.map +1 -1
  15. package/dist/models/ReviewModel.js +20 -1
  16. package/dist/models/UserModel.d.ts +2 -0
  17. package/dist/models/UserModel.d.ts.map +1 -1
  18. package/dist/models/UserModel.js +9 -0
  19. package/package.json +1 -1
  20. package/dist/app.js +0 -59
  21. package/dist/common/configs/express.js +0 -29
  22. package/dist/common/configs/websocket.js +0 -17
  23. package/dist/common/constants/chat.d.ts +0 -18
  24. package/dist/common/constants/chat.d.ts.map +0 -1
  25. package/dist/common/constants/chat.js +0 -20
  26. package/dist/common/constants/messages/admin.messages.d.ts +0 -33
  27. package/dist/common/constants/messages/admin.messages.d.ts.map +0 -1
  28. package/dist/common/constants/messages/admin.messages.js +0 -35
  29. package/dist/common/constants/messages/user.messages.d.ts +0 -33
  30. package/dist/common/constants/messages/user.messages.d.ts.map +0 -1
  31. package/dist/common/constants/messages/user.messages.js +0 -35
  32. package/dist/common/dtos/AdminDto.d.ts +0 -5
  33. package/dist/common/dtos/AdminDto.d.ts.map +0 -1
  34. package/dist/common/dtos/AdminDto.js +0 -30
  35. package/dist/common/dtos/ArticleDto.d.ts +0 -11
  36. package/dist/common/dtos/ArticleDto.d.ts.map +0 -1
  37. package/dist/common/dtos/ArticleDto.js +0 -61
  38. package/dist/common/dtos/BusinessDto.d.ts +0 -12
  39. package/dist/common/dtos/BusinessDto.d.ts.map +0 -1
  40. package/dist/common/dtos/BusinessDto.js +0 -59
  41. package/dist/common/dtos/ChatDto.d.ts +0 -17
  42. package/dist/common/dtos/ChatDto.d.ts.map +0 -1
  43. package/dist/common/dtos/ChatDto.js +0 -89
  44. package/dist/common/dtos/CommonDto.d.ts +0 -13
  45. package/dist/common/dtos/CommonDto.d.ts.map +0 -1
  46. package/dist/common/dtos/CommonDto.js +0 -59
  47. package/dist/common/dtos/CommunityDto.d.ts +0 -10
  48. package/dist/common/dtos/CommunityDto.d.ts.map +0 -1
  49. package/dist/common/dtos/CommunityDto.js +0 -72
  50. package/dist/common/dtos/EventDto.d.ts +0 -24
  51. package/dist/common/dtos/EventDto.d.ts.map +0 -1
  52. package/dist/common/dtos/EventDto.js +0 -72
  53. package/dist/common/dtos/IPaginator.d.ts +0 -15
  54. package/dist/common/dtos/IPaginator.d.ts.map +0 -1
  55. package/dist/common/dtos/IPaginator.js +0 -40
  56. package/dist/common/dtos/Plan.dto.d.ts +0 -10
  57. package/dist/common/dtos/Plan.dto.d.ts.map +0 -1
  58. package/dist/common/dtos/Plan.dto.js +0 -66
  59. package/dist/common/dtos/PostDto.d.ts +0 -13
  60. package/dist/common/dtos/PostDto.d.ts.map +0 -1
  61. package/dist/common/dtos/PostDto.js +0 -75
  62. package/dist/common/dtos/ProductDto.d.ts +0 -13
  63. package/dist/common/dtos/ProductDto.d.ts.map +0 -1
  64. package/dist/common/dtos/ProductDto.js +0 -66
  65. package/dist/common/dtos/ServiceDto.d.ts +0 -19
  66. package/dist/common/dtos/ServiceDto.d.ts.map +0 -1
  67. package/dist/common/dtos/ServiceDto.js +0 -93
  68. package/dist/common/dtos/UserDto.d.ts +0 -70
  69. package/dist/common/dtos/UserDto.d.ts.map +0 -1
  70. package/dist/common/dtos/UserDto.js +0 -313
  71. package/dist/common/types/IPagination.d.ts +0 -15
  72. package/dist/common/types/IPagination.d.ts.map +0 -1
  73. package/dist/common/types/IPagination.js +0 -2
  74. package/dist/common/utils/axios.js +0 -26
  75. package/dist/common/utils/socket.js +0 -16
  76. package/dist/database/seeds/CommunityDataSeeder.js +0 -48
  77. package/dist/database/seeds/EventDataSeeder.js +0 -54
  78. package/dist/database/seeds/FeatureSeeder.js +0 -131
  79. package/dist/database/seeds/MarketplaceDataSeeder.js +0 -95
  80. package/dist/database/seeds/PlanSeeder.js +0 -78
  81. package/dist/database/seeds/UserProfileDataSeeder.js +0 -215
  82. package/dist/database/seeds/index.js +0 -39
  83. package/dist/services/StripeService.js +0 -288
  84. package/dist/services/mobile/ArticleCommentService.js +0 -479
  85. package/dist/services/mobile/ArticleService.js +0 -507
  86. package/dist/services/mobile/AuthService.js +0 -362
  87. package/dist/services/mobile/BusinessService.js +0 -267
  88. package/dist/services/mobile/BusinessServiceService.js +0 -383
  89. package/dist/services/mobile/CardService.js +0 -249
  90. package/dist/services/mobile/ChatService.js +0 -324
  91. package/dist/services/mobile/CommunityMemberService.js +0 -193
  92. package/dist/services/mobile/CommunityService.js +0 -561
  93. package/dist/services/mobile/CompleteProfileService.js +0 -308
  94. package/dist/services/mobile/ConnectionService.js +0 -338
  95. package/dist/services/mobile/EventAttendanceService.js +0 -343
  96. package/dist/services/mobile/EventService.js +0 -540
  97. package/dist/services/mobile/NotificationService.js +0 -89
  98. package/dist/services/mobile/PasswordResetService.js +0 -168
  99. package/dist/services/mobile/PlanService.js +0 -85
  100. package/dist/services/mobile/PostCommentService.js +0 -611
  101. package/dist/services/mobile/PostService.js +0 -640
  102. package/dist/services/mobile/ProductService.js +0 -360
  103. package/dist/services/mobile/RedisService.js +0 -16
  104. package/dist/services/mobile/TransactionService.js +0 -51
  105. package/dist/services/mobile/UploadService.js +0 -110
  106. package/dist/services/mobile/UserService.js +0 -128
@@ -1,507 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const typedi_1 = require("typedi");
16
- const logger_1 = require("../../common/configs/logger");
17
- const AppError_1 = require("../../common/errors/AppError");
18
- const messages_1 = require("../../common/constants/messages");
19
- const UploadService_1 = __importDefault(require("./UploadService"));
20
- const UploadEnum_1 = require("@/common/enums/UploadEnum");
21
- const ArticleRepository_1 = require("@/repositories/ArticleRepository");
22
- const ArticleImageRepository_1 = require("@/repositories/ArticleImageRepository");
23
- const ArticleCollection_1 = require("../../transformers/collections/ArticleCollection");
24
- const Paginator_1 = require("@/transformers/Paginator");
25
- const configs_1 = require("@/common/configs");
26
- const ArticleResource_1 = require("@/transformers/resources/ArticleResource");
27
- const CommunityRepository_1 = require("@/repositories/CommunityRepository");
28
- const ArticleLikeRepository_1 = require("@/repositories/ArticleLikeRepository");
29
- const IndexEnum_1 = require("@/common/enums/IndexEnum");
30
- const ArticleCommentModel_1 = __importDefault(require("@/models/ArticleCommentModel"));
31
- const LikeModel_1 = __importDefault(require("@/models/LikeModel"));
32
- const ArticleImageModel_1 = __importDefault(require("@/models/ArticleImageModel"));
33
- let ArticleService = class ArticleService {
34
- articleRepository;
35
- uploadService;
36
- articleImageRepository;
37
- communityRepository;
38
- likeRepository;
39
- constructor() {
40
- this.articleRepository = new ArticleRepository_1.ArticleRepository();
41
- this.uploadService = new UploadService_1.default();
42
- this.articleImageRepository = new ArticleImageRepository_1.ArticleImageRepository();
43
- this.communityRepository = new CommunityRepository_1.CommunityRepository();
44
- this.likeRepository = new ArticleLikeRepository_1.ArticleLikeRepository();
45
- }
46
- async createArticle(articleData, user_id) {
47
- let message;
48
- const { title, visibility, is_sensitive, article_images, description, } = articleData;
49
- if (article_images && article_images?.length > 5) {
50
- message = "Maximum of 5 images allowed";
51
- logger_1.logger.error(message);
52
- throw new AppError_1.AppError(message, 422);
53
- }
54
- const createdArticle = await this.articleRepository.create({
55
- title: title ?? null,
56
- visibility,
57
- is_sensitive,
58
- description,
59
- user_id
60
- });
61
- const articleId = createdArticle.id;
62
- logger_1.logger.info("Article created without cover image");
63
- if (article_images?.length) {
64
- const uploadedFiles = await Promise.all(article_images.map((article_image) => this.uploadService.uploadImage(article_image, articleId, UploadEnum_1.UploadDirectories.ARTICLE_IMAGES, "ArticleModel")));
65
- await Promise.all(uploadedFiles.map((file) => this.articleImageRepository.create({
66
- article_id: articleId,
67
- image_id: file.id,
68
- })));
69
- }
70
- return {
71
- successful: true,
72
- data: {
73
- article: {
74
- created_at: createdArticle.created_at
75
- }
76
- },
77
- message: "Article created successfully"
78
- };
79
- }
80
- async getOneArticle(article_id, user_id) {
81
- let message;
82
- const foundArticle = await this.articleRepository.basicFindOneByConditions({
83
- uuid: article_id
84
- });
85
- if (!foundArticle) {
86
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
87
- logger_1.logger.info(message);
88
- throw new AppError_1.AppError(message, 404);
89
- }
90
- const qb = this.articleRepository
91
- .getRepo()
92
- .createQueryBuilder("article")
93
- .leftJoin("article.user", "user")
94
- .where("article.deleted_at IS NULL")
95
- .andWhere("article.uuid = :articleId", {
96
- articleId: article_id,
97
- });
98
- /* ======================
99
- ARTICLE FIELDS
100
- ====================== */
101
- qb.select([
102
- "article.id",
103
- "article.uuid",
104
- "article.title",
105
- "article.description",
106
- "article.visibility",
107
- "article.is_sensitive",
108
- "article.created_at",
109
- "user.id",
110
- "user.uuid",
111
- "user.full_name",
112
- ]);
113
- // Check if the user has liked the article
114
- qb.addSelect(`
115
- EXISTS (
116
- SELECT 1
117
- FROM likes l
118
- WHERE l.likeable_id = article.id
119
- AND l.likeable_type = :articleType
120
- AND l.user_id = :user_id
121
- AND l.deleted_at IS NULL
122
- )
123
- `, "has_liked")
124
- .setParameter("articleType", IndexEnum_1.SYS_MODELS.ARTICLE_MODEL)
125
- .setParameter("user_id", user_id);
126
- /* ======================
127
- TOTAL COMMENTS COUNT
128
- ====================== */
129
- qb.addSelect(subQuery => {
130
- return subQuery
131
- .select("COUNT(c.id)")
132
- .from(ArticleCommentModel_1.default, "c")
133
- .where("c.article_id = article.id")
134
- .andWhere("c.deleted_at IS NULL");
135
- }, "comments_count");
136
- /* ======================
137
- TOTAL ARTICLE LIKES
138
- ====================== */
139
- qb.addSelect(subQuery => {
140
- return subQuery
141
- .select("COUNT(l.id)")
142
- .from(LikeModel_1.default, "l")
143
- .where("l.likeable_id = article.id")
144
- .andWhere("l.likeable_type = :articleType");
145
- }, "likes_count")
146
- .setParameter("articleType", IndexEnum_1.SYS_MODELS.ARTICLE_MODEL);
147
- /* ======================
148
- LAST 4 COMMENTS (WITH META)
149
- ====================== */
150
- qb.addSelect(subQuery => {
151
- return subQuery
152
- .select(`
153
- COALESCE(
154
- json_agg(
155
- json_build_object(
156
- 'id', c.c_id,
157
- 'uuid', c.c_uuid,
158
- 'content', c.c_content,
159
- 'created_at', c.c_created_at,
160
-
161
- 'user', json_build_object(
162
- 'id', c.u_id,
163
- 'uuid', c.u_uuid,
164
- 'full_name', c.u_full_name
165
- ),
166
-
167
- 'likes_count', (
168
- SELECT COUNT(*)
169
- FROM likes cl
170
- WHERE cl.likeable_id = c.c_id
171
- AND cl.likeable_type = '${IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL}'
172
- ),
173
-
174
- 'replies_count', (
175
- SELECT COUNT(*)
176
- FROM comments r
177
- WHERE r.parent_id = c.c_id
178
- AND r.deleted_at IS NULL
179
- )
180
- )
181
- ORDER BY c.c_created_at DESC
182
- ),
183
- '[]'
184
- )
185
- `)
186
- .from(qb2 => {
187
- return qb2
188
- .select([
189
- "c.id AS c_id",
190
- "c.uuid AS c_uuid",
191
- "c.created_at AS c_created_at",
192
- "c.content AS c_content",
193
- "u.id AS u_id",
194
- "u.uuid AS u_uuid",
195
- "u.full_name AS u_full_name",
196
- ])
197
- .from(ArticleCommentModel_1.default, "c")
198
- .leftJoin("c.user", "u")
199
- .where("c.article_id = article.id")
200
- .andWhere("c.parent_id IS NULL")
201
- .andWhere("c.deleted_at IS NULL")
202
- .orderBy("c.created_at", "DESC")
203
- .limit(4);
204
- }, "c");
205
- }, "last_comments");
206
- /* ======================
207
- IMAGES (JSON AGG)
208
- ====================== */
209
- qb.addSelect(subQuery => {
210
- return subQuery
211
- .select(`
212
- COALESCE(
213
- json_agg(
214
- json_build_object(
215
- 'id', pi.pi_id,
216
- 'uuid', pi.pi_uuid,
217
- 'file_name', pi.file_name,
218
- 'file_size', pi.file_size,
219
- 'file_mimetype', pi.file_mimetype,
220
- 'url', pi.url
221
- )
222
- ORDER BY pi.pi_created_at ASC
223
- ) FILTER (WHERE pi.pi_id IS NOT NULL),
224
- '[]'
225
- )
226
- `)
227
- .from(qb2 => {
228
- return qb2
229
- .select([
230
- "pi.id AS pi_id",
231
- "pi.uuid AS pi_uuid",
232
- "pi.created_at AS pi_created_at",
233
- "u.file_name AS file_name",
234
- "u.file_size AS file_size",
235
- "u.file_mimetype AS file_mimetype",
236
- "u.url AS url",
237
- ])
238
- .from(ArticleImageModel_1.default, "pi")
239
- .leftJoin("pi.upload", "u")
240
- .where("pi.article_id = article.id")
241
- .andWhere("pi.deleted_at IS NULL")
242
- .andWhere("u.deleted_at IS NULL");
243
- }, "pi");
244
- }, "images");
245
- /* ======================
246
- ORDERING
247
- ====================== */
248
- qb.orderBy("article.created_at", "DESC");
249
- /* ======================
250
- PAGINATION
251
- ====================== */
252
- const { entities, raw } = await qb.getRawAndEntities();
253
- const article = entities;
254
- if (!article[0] || !raw[0]) {
255
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
256
- logger_1.logger.info(message);
257
- throw new AppError_1.AppError(message, 404);
258
- }
259
- return {
260
- successful: true,
261
- data: ArticleResource_1.ArticleResource.toJSON(raw[0], article[0], user_id),
262
- message: "Article fetched successfully!"
263
- };
264
- }
265
- async getPagedArticles(user_id, pageNumber) {
266
- let message;
267
- const page_number = pageNumber || 1;
268
- const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
269
- const { data: articles, total, perPage, page } = await this.articleRepository.getPagedArticles({
270
- page_number,
271
- limit
272
- }, user_id);
273
- const { entities, raw } = articles;
274
- const articlesData = (0, Paginator_1.paginator)({
275
- total: total,
276
- perPage: perPage,
277
- currentPage: page,
278
- data: ArticleCollection_1.ArticleCollection.toJSON(raw, entities),
279
- });
280
- return {
281
- successful: true,
282
- data: articlesData,
283
- message: "articles fetched successfully!"
284
- };
285
- }
286
- async getArticles(user_id, community_id, pageNumber) {
287
- let message;
288
- const page_number = pageNumber || 1;
289
- const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
290
- const community = await this.communityRepository.basicFindOneByConditions({
291
- uuid: community_id
292
- });
293
- if (!community) {
294
- message = messages_1.dynamic_messages.NOT_FOUND("Community");
295
- logger_1.logger.info(message);
296
- throw new AppError_1.AppError(message, 404);
297
- }
298
- const dataFetchParams = {
299
- page_number,
300
- limit,
301
- metadata: {
302
- community_id: community.id
303
- }
304
- };
305
- const articles = await this.loadPaginatedArticles(dataFetchParams, user_id);
306
- if (!articles) {
307
- message = messages_1.dynamic_messages.NOT_FOUND("articles");
308
- logger_1.logger.info(message);
309
- throw new AppError_1.AppError(message, 404);
310
- }
311
- return {
312
- successful: true,
313
- data: articles,
314
- message: "articles fetched successfully!"
315
- };
316
- }
317
- async loadPaginatedArticles(paginationDto, userId) {
318
- try {
319
- const { data, total, perPage, page } = await this.articleRepository.getPagedArticles(paginationDto, userId);
320
- const { entities, raw } = data;
321
- return (0, Paginator_1.paginator)({
322
- total: total,
323
- perPage: perPage,
324
- currentPage: page,
325
- data: ArticleCollection_1.ArticleCollection.toJSON(raw, entities),
326
- });
327
- }
328
- catch (error) {
329
- logger_1.logger.error("Error loading messages:", {
330
- error: error.message,
331
- stack: error.stack,
332
- });
333
- throw error;
334
- }
335
- }
336
- async updateOneArticle(articleData, article_id, user_id) {
337
- let message;
338
- const { title, visibility, is_sensitive, description, } = articleData;
339
- const article = await this.articleRepository.basicFindOneByConditions({
340
- uuid: article_id,
341
- user_id
342
- });
343
- if (!article) {
344
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
345
- logger_1.logger.info(message);
346
- throw new AppError_1.AppError(message, 404);
347
- }
348
- const updatedArticle = await this.articleRepository.updateOne({
349
- uuid: article.uuid,
350
- user_id,
351
- }, {
352
- title: title ?? null,
353
- visibility,
354
- is_sensitive,
355
- description,
356
- });
357
- return {
358
- successful: true,
359
- data: updatedArticle,
360
- message: "Article updated successfully!"
361
- };
362
- }
363
- async likeOrUnlikeArticle(article_id, user_id) {
364
- let message;
365
- const article = await this.articleRepository.basicFindOneByConditions({
366
- uuid: article_id,
367
- user_id
368
- });
369
- if (!article) {
370
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
371
- logger_1.logger.info(message);
372
- throw new AppError_1.AppError(message, 404);
373
- }
374
- const alreadyLikedArticle = await this.likeRepository.basicFindOneByConditions({
375
- likeable_id: article.id,
376
- likeable_type: IndexEnum_1.SYS_MODELS.ARTICLE_MODEL,
377
- user_id
378
- });
379
- if (alreadyLikedArticle) {
380
- // Unlike the article
381
- await this.likeRepository.deleteByCondition({
382
- user_id,
383
- likeable_id: article.id,
384
- likeable_type: IndexEnum_1.SYS_MODELS.ARTICLE_MODEL
385
- });
386
- message = "Article unliked successfully";
387
- }
388
- else {
389
- // Like the article
390
- await this.likeRepository.create({
391
- user_id,
392
- likeable_id: article.id,
393
- likeable_type: IndexEnum_1.SYS_MODELS.ARTICLE_MODEL
394
- });
395
- message = "Article liked successfully";
396
- }
397
- return {
398
- successful: true,
399
- data: null,
400
- message
401
- };
402
- }
403
- async deleteOneArticle(article_id, user_id) {
404
- let message;
405
- const article = await this.articleRepository.basicFindOneByConditions({
406
- uuid: article_id,
407
- user_id
408
- });
409
- if (!article) {
410
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
411
- logger_1.logger.info(message);
412
- throw new AppError_1.AppError(message, 404);
413
- }
414
- const articleUploads = await this.articleImageRepository.basicFindManyByConditions({
415
- article_id: article.id
416
- });
417
- if (articleUploads?.length) {
418
- await Promise.all(articleUploads.map((article_image) => this.uploadService.deleteFile(article_image.image_id, article_image?.article_id, "image")));
419
- await this.articleImageRepository.deleteByCondition({ article_id: article.id });
420
- }
421
- await this.articleRepository.deleteByCondition({
422
- uuid: article.uuid,
423
- user_id,
424
- });
425
- return {
426
- successful: true,
427
- data: null,
428
- message: "Article deleted successfully!"
429
- };
430
- }
431
- async deleteArticleUpload(article_id, article_image_id, user_id) {
432
- let message;
433
- const article = await this.articleRepository.basicFindOneByConditions({
434
- uuid: article_id,
435
- user_id
436
- });
437
- if (!article) {
438
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
439
- logger_1.logger.info(message);
440
- throw new AppError_1.AppError(message, 404);
441
- }
442
- const articleUpload = await this.articleImageRepository.basicFindOneByConditions({
443
- article_id: article.id,
444
- uuid: article_image_id
445
- });
446
- if (!articleUpload) {
447
- message = messages_1.dynamic_messages.NOT_FOUND("Article File");
448
- logger_1.logger.info(message);
449
- throw new AppError_1.AppError(message, 404);
450
- }
451
- this.uploadService.deleteFile(articleUpload.image_id, articleUpload?.article_id, "image");
452
- await this.articleImageRepository.deleteByCondition({ article_id: article.id });
453
- return {
454
- successful: true,
455
- data: null,
456
- message: "Article image deleted successfully!"
457
- };
458
- }
459
- async getUserThatLikedArticle(article_id, user_id, pageNumber) {
460
- let message;
461
- const article = await this.articleRepository.basicFindOneByConditions({
462
- uuid: article_id
463
- });
464
- if (!article) {
465
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
466
- logger_1.logger.info(message);
467
- throw new AppError_1.AppError(message, 404);
468
- }
469
- const page_number = pageNumber || 1;
470
- const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
471
- const dataFetchParams = {
472
- page_number,
473
- limit,
474
- metadata: {
475
- article_id: article.id
476
- }
477
- };
478
- const { data, total, perPage, page } = await this.likeRepository.getPagedArticleUserLikes(dataFetchParams, user_id);
479
- const { entities, raw } = data;
480
- const articleUserLikes = raw.map((like) => {
481
- return {
482
- user: {
483
- name: like?.user_full_name,
484
- uuid: like?.user_uuid,
485
- avatar_url: like?.avatar_url,
486
- },
487
- liked_at: like?.like_created_at
488
- };
489
- });
490
- const articleLikes = (0, Paginator_1.paginator)({
491
- total: total,
492
- perPage: perPage,
493
- currentPage: page,
494
- data: articleUserLikes,
495
- });
496
- return {
497
- successful: true,
498
- data: articleLikes,
499
- message: "User likes fetched successfully!"
500
- };
501
- }
502
- };
503
- ArticleService = __decorate([
504
- (0, typedi_1.Service)(),
505
- __metadata("design:paramtypes", [])
506
- ], ArticleService);
507
- exports.default = ArticleService;