All files / apps/api-gateway/src/gateway/clients properties.client.ts

100% Statements 10/10
100% Branches 4/4
100% Functions 4/4
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 274x   4x     4x   6x             1x       2x 2x       2x      
import { Injectable } from '@nestjs/common';
import { Paginated, PropertyDto } from '../http/api-types';
import { DownstreamClient } from '../http/downstream.client';
 
@Injectable()
export class PropertiesClient extends DownstreamClient {
  constructor() {
    super(
      process.env.PROPERTIES_URL ?? 'http://localhost:3003',
      'properties service',
    );
  }
 
  create(body: unknown): Promise<PropertyDto> {
    return this.post('/properties', body);
  }
 
  list(query: Record<string, string>): Promise<Paginated<PropertyDto>> {
    const search = new URLSearchParams(query).toString();
    return this.get(`/properties${search ? `?${search}` : ''}`);
  }
 
  getById(id: string): Promise<PropertyDto> {
    return this.get(`/properties/${id}`);
  }
}