From 109fbeb34d3b1a7376dea48e488b4ab1f8db1324 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 6 Jun 2026 15:51:12 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BE=D1=84=D1=84=D0=B5=D1=80=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/modules/offer/offer-controller.ts | 2 +- src/shared/modules/offer/offer-service.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/shared/modules/offer/offer-controller.ts b/src/shared/modules/offer/offer-controller.ts index fe2a96c..cd7b6f8 100644 --- a/src/shared/modules/offer/offer-controller.ts +++ b/src/shared/modules/offer/offer-controller.ts @@ -109,7 +109,7 @@ export class OfferController extends BaseController { } public async index(req: Request, res: Response) { - const limit = Number(req.params.limit) || MAX_DISPLAY_OFFERS_COUNT; + const limit = Number(req.query.limit) || MAX_DISPLAY_OFFERS_COUNT; const offers = await this.offerService.find(limit); let favoritesIds: string[] = []; diff --git a/src/shared/modules/offer/offer-service.ts b/src/shared/modules/offer/offer-service.ts index b2ae901..ca92eaf 100644 --- a/src/shared/modules/offer/offer-service.ts +++ b/src/shared/modules/offer/offer-service.ts @@ -68,7 +68,12 @@ export class OfferService implements OfferServiceInterface, DocumentExists { } async find(limit: number): Promise[]> { - return this.offerModel.find().populate('host').limit(limit).exec(); + return this.offerModel + .find() + .populate('host') + .sort({ date: -1 }) + .limit(limit) + .exec(); } async findPremiumOffersByCity( From 4131be8084853a22f10d0bf9683fb19bf8999289 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 6 Jun 2026 16:03:21 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D1=81=D0=BF?= =?UTF-8?q?=D0=B5=D1=86=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- specification/specification.yml | 4 ++-- src/shared/modules/offer/offer-service.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/specification/specification.yml b/specification/specification.yml index 423f3f8..d2c3ab6 100644 --- a/specification/specification.yml +++ b/specification/specification.yml @@ -340,7 +340,7 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' - '403': + '401': description: Пользователь не авторизован content: application/json: @@ -373,7 +373,7 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' - '403': + '401': description: Пользователь не авторизован content: application/json: diff --git a/src/shared/modules/offer/offer-service.ts b/src/shared/modules/offer/offer-service.ts index ca92eaf..d85d36d 100644 --- a/src/shared/modules/offer/offer-service.ts +++ b/src/shared/modules/offer/offer-service.ts @@ -107,9 +107,13 @@ export class OfferService implements OfferServiceInterface, DocumentExists { userId: string, ): Promise | null> { const result = await this.userModel - .findByIdAndUpdate(userId, { - $addToSet: { favorites: new mongoose.Types.ObjectId(offerId) }, - }) + .findByIdAndUpdate( + userId, + { + $addToSet: { favorites: new mongoose.Types.ObjectId(offerId) }, + }, + { new: true }, + ) .exec(); return result;