From 54ad6a4882637fcc38e2e7ada3197cd7f1f2e31e Mon Sep 17 00:00:00 2001 From: okjodom Date: Wed, 27 Nov 2024 20:32:16 +0300 Subject: [PATCH] chore: simplify dto --- apps/api/src/admin/admin.controller.spec.ts | 12 ++++---- apps/api/src/admin/admin.controller.ts | 4 +-- apps/api/src/admin/admin.service.ts | 6 ++-- apps/api/src/api.module.ts | 8 +++++- libs/common/src/dto/index.ts | 2 -- libs/common/src/dto/nostr.dto.ts | 7 ++++- libs/common/src/dto/payments.dto.ts | 18 ------------ libs/common/src/dto/quote.dto.ts | 15 ---------- libs/common/src/dto/swap.dto.ts | 32 +++++++++++++++++++-- libs/common/src/types/api.ts | 2 +- 10 files changed, 53 insertions(+), 53 deletions(-) delete mode 100644 libs/common/src/dto/payments.dto.ts delete mode 100644 libs/common/src/dto/quote.dto.ts diff --git a/apps/api/src/admin/admin.controller.spec.ts b/apps/api/src/admin/admin.controller.spec.ts index 751104f..81a66ee 100644 --- a/apps/api/src/admin/admin.controller.spec.ts +++ b/apps/api/src/admin/admin.controller.spec.ts @@ -19,12 +19,12 @@ describe('AdminController', () => { hasShares: false, }, swapStatus: { - isRunning: true - } - }) - } - } - ] + isRunning: true, + }, + }), + }, + }, + ], }); controller = module.get(AdminController); diff --git a/apps/api/src/admin/admin.controller.ts b/apps/api/src/admin/admin.controller.ts index 153d114..b907509 100644 --- a/apps/api/src/admin/admin.controller.ts +++ b/apps/api/src/admin/admin.controller.ts @@ -6,9 +6,7 @@ import { AdminService } from './admin.service'; export class AdminController { private readonly logger = new Logger(AdminController.name); - constructor( - private readonly adminService: AdminService, - ) { + constructor(private readonly adminService: AdminService) { this.logger.log('AdminController initialized'); } diff --git a/apps/api/src/admin/admin.service.ts b/apps/api/src/admin/admin.service.ts index fba2be4..1044829 100644 --- a/apps/api/src/admin/admin.service.ts +++ b/apps/api/src/admin/admin.service.ts @@ -6,11 +6,11 @@ export class AdminService { async getStatus(): Promise { return { memberStatus: { - hasShares: false + hasShares: false, }, swapStatus: { - isRunning: true + isRunning: true, }, - } + }; } } diff --git a/apps/api/src/api.module.ts b/apps/api/src/api.module.ts index a5c37d9..5c9eac9 100644 --- a/apps/api/src/api.module.ts +++ b/apps/api/src/api.module.ts @@ -104,6 +104,12 @@ import { AdminService } from './admin/admin.service'; SmsController, SharesController, ], - providers: [SwapService, NostrService, SmsService, SharesService, AdminService], + providers: [ + SwapService, + NostrService, + SmsService, + SharesService, + AdminService, + ], }) export class ApiModule {} diff --git a/libs/common/src/dto/index.ts b/libs/common/src/dto/index.ts index 9f63ccc..47d48bd 100644 --- a/libs/common/src/dto/index.ts +++ b/libs/common/src/dto/index.ts @@ -1,6 +1,4 @@ - export * from './swap.dto'; -export * from './quote.dto'; export * from './nostr.dto'; export * from './sms.dto'; export * from './shares.dto'; diff --git a/libs/common/src/dto/nostr.dto.ts b/libs/common/src/dto/nostr.dto.ts index 9e7b4ce..0162ad8 100644 --- a/libs/common/src/dto/nostr.dto.ts +++ b/libs/common/src/dto/nostr.dto.ts @@ -9,7 +9,12 @@ import { } from 'class-validator'; import { Type } from 'class-transformer'; import { ApiProperty } from '@nestjs/swagger'; -import { ConfigureNostrRelaysRequest, NostrDirectMessageRequest, NostrRecipient, NostrRelay } from '../types'; +import { + ConfigureNostrRelaysRequest, + NostrDirectMessageRequest, + NostrRecipient, + NostrRelay, +} from '../types'; class NostrRecipientDto implements NostrRecipient { @IsOptional() diff --git a/libs/common/src/dto/payments.dto.ts b/libs/common/src/dto/payments.dto.ts deleted file mode 100644 index 08ca5d2..0000000 --- a/libs/common/src/dto/payments.dto.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Type } from 'class-transformer'; -import { IsString } from 'class-validator'; -import { ApiProperty } from '@nestjs/swagger'; -import { Bolt11, MobileMoney } from '../types'; - -export class MobileMoneyDto implements MobileMoney { - @IsString() - @Type(() => String) - @ApiProperty() - phone: string; -} - -export class Bolt11InvoiceDto implements Bolt11 { - @IsString() - @Type(() => String) - @ApiProperty() - invoice: string; -} diff --git a/libs/common/src/dto/quote.dto.ts b/libs/common/src/dto/quote.dto.ts deleted file mode 100644 index 88bb8da..0000000 --- a/libs/common/src/dto/quote.dto.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { Type } from 'class-transformer'; -import { IsBoolean, IsString } from 'class-validator'; - -export class QuoteDto { - @IsString() - @Type(() => String) - @ApiProperty() - id: string; - - @IsBoolean() - @Type(() => Boolean) - @ApiProperty() - refreshIfExpired: boolean; -} diff --git a/libs/common/src/dto/swap.dto.ts b/libs/common/src/dto/swap.dto.ts index 29fcd86..d965ae0 100644 --- a/libs/common/src/dto/swap.dto.ts +++ b/libs/common/src/dto/swap.dto.ts @@ -8,6 +8,7 @@ import { ValidateNested, IsNumber, Min, + IsBoolean, } from 'class-validator'; import { Type } from 'class-transformer'; import { ApiProperty } from '@nestjs/swagger'; @@ -22,10 +23,36 @@ import { OfframpSwapRequest, OfframpSwapTarget, PaginatedRequest, + MobileMoney, + Bolt11, } from '../types'; -import { Bolt11InvoiceDto, MobileMoneyDto } from './payments.dto'; import { TransformToCurrency } from './transforms'; -import { QuoteDto } from './quote.dto'; + +export class QuoteDto { + @IsString() + @Type(() => String) + @ApiProperty() + id: string; + + @IsBoolean() + @Type(() => Boolean) + @ApiProperty() + refreshIfExpired: boolean; +} + +export class MobileMoneyDto implements MobileMoney { + @IsString() + @Type(() => String) + @ApiProperty() + phone: string; +} + +export class Bolt11InvoiceDto implements Bolt11 { + @IsString() + @Type(() => String) + @ApiProperty() + invoice: string; +} class OnrampSwapSourceDto implements OnrampSwapSource { @IsEnum(Currency) @@ -81,7 +108,6 @@ export class CreateOnrampSwapDto implements OnrampSwapRequest { target: OnrampSwapTargetDto; } - class OfframpSwapTargetDto implements OfframpSwapTarget { @IsEnum(Currency) @TransformToCurrency() diff --git a/libs/common/src/types/api.ts b/libs/common/src/types/api.ts index 73d7d52..1771cde 100644 --- a/libs/common/src/types/api.ts +++ b/libs/common/src/types/api.ts @@ -20,7 +20,7 @@ interface MemberStatus { } interface ServiceStatus { - isRunning: boolean + isRunning: boolean; } export interface BitsaccoStatus {