Skip to content

Commit

Permalink
module7-task1: update visual code fox exists method and fix limit que…
Browse files Browse the repository at this point in the history
…ry param
  • Loading branch information
JIlyaS committed Nov 1, 2024
1 parent 02c8a10 commit 4f78266
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/shared/modules/offer/default-offer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ export class DefaultOfferService implements OfferService {

// TODO: проверка на существование документа - предложения
public async exists(documentId: string): Promise<boolean> {
return (await this.offerModel
.exists({_id: documentId})) !== null;
return this.offerModel.exists({_id: documentId}).then(r => !!r);

Check failure on line 110 in src/shared/modules/offer/default-offer.service.ts

View workflow job for this annotation

GitHub Actions / Check

Expected parentheses around arrow function argument
}


Expand Down
1 change: 1 addition & 0 deletions src/shared/modules/offer/offer.constant.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const DEFAULT_OFFER_COUNT = 60;
export const DEFAULT_PREMIUM_OFFER_COUNT = 3;
export const MAX_OFFER_COUNT = 300;
5 changes: 3 additions & 2 deletions src/shared/modules/offer/offer.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { fillDTO } from '../../helpers/common.js';
import { FullOfferRdo } from './rdo/full-offer.rdo.js';
import { StatusCodes } from 'http-status-codes';
import { UpdateOfferDto } from './dto/update-offer.dto.js';
import { DEFAULT_OFFER_COUNT } from './offer.constant.js';
import { DEFAULT_OFFER_COUNT, MAX_OFFER_COUNT } from './offer.constant.js';
import { IdOfferRdo } from './rdo/id-offer.rdo.js';
import { ParamOfferId } from './type/param-offerid.type.js';
import { CreateOfferRequest } from './type/create-offer-request.type.js';
Expand Down Expand Up @@ -48,7 +48,8 @@ export class OfferController extends BaseController {
}

public async index({ query } : Request<unknown, unknown, unknown, RequestQuery>, res: Response): Promise<void> {
const limit = query?.limit ? Number(query.limit) : DEFAULT_OFFER_COUNT;
const limitNum = Number(query?.limit);
const limit = query?.limit && !Number.isNaN(limitNum) && limitNum < MAX_OFFER_COUNT ? limitNum : DEFAULT_OFFER_COUNT;

// TODO: Временно сделать const userId = '<ID>';
// const userId = req.user.id // AFTER JWT
Expand Down
3 changes: 1 addition & 2 deletions src/shared/modules/user/default-user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export class DefaultUserService implements UserService {

// TODO: проверка на существование документа - предложения
public async exists(documentId: string): Promise<boolean> {
return (await this.userModel
.exists({_id: documentId})) !== null;
return this.userModel.exists({_id: documentId}).then(r => !!r);

Check failure on line 33 in src/shared/modules/user/default-user.service.ts

View workflow job for this annotation

GitHub Actions / Check

Expected parentheses around arrow function argument
}

public async findByEmail(email: string): Promise<DocumentType<UserEntity> | null> {
Expand Down

0 comments on commit 4f78266

Please sign in to comment.