From 7bcd7fa10d08b5b55748ccd2bb75879c899edba0 Mon Sep 17 00:00:00 2001 From: barsa Date: Thu, 15 Jan 2026 16:41:58 +0900 Subject: [PATCH] refactor: remove unused DTOs and guards from auth and billing controllers --- .../auth/presentation/http/auth.controller.ts | 20 -------- .../src/modules/billing/billing.controller.ts | 46 +------------------ .../bff/src/modules/users/users.controller.ts | 12 ----- package.json | 2 +- 4 files changed, 3 insertions(+), 77 deletions(-) diff --git a/apps/bff/src/modules/auth/presentation/http/auth.controller.ts b/apps/bff/src/modules/auth/presentation/http/auth.controller.ts index b3d6b86c..d9a22e5f 100644 --- a/apps/bff/src/modules/auth/presentation/http/auth.controller.ts +++ b/apps/bff/src/modules/auth/presentation/http/auth.controller.ts @@ -21,7 +21,6 @@ import { LoginResultInterceptor } from "./interceptors/login-result.interceptor. import { Public, OptionalAuth } from "../../decorators/public.decorator.js"; import { createZodDto, ZodResponse } from "nestjs-zod"; import type { RequestWithUser } from "@bff/modules/auth/auth.types.js"; -import { SalesforceReadThrottleGuard } from "@bff/integrations/salesforce/guards/salesforce-read-throttle.guard.js"; import { SalesforceWriteThrottleGuard } from "@bff/integrations/salesforce/guards/salesforce-write-throttle.guard.js"; import { JoseJwtService } from "../../infra/token/jose-jwt.service.js"; import type { UserAuth } from "@customer-portal/domain/customer"; @@ -35,7 +34,6 @@ import { setPasswordRequestSchema, linkWhmcsRequestSchema, changePasswordRequestSchema, - validateSignupRequestSchema, accountStatusRequestSchema, ssoLinkRequestSchema, checkPasswordNeededRequestSchema, @@ -49,7 +47,6 @@ type RequestWithCookies = Omit & { cookies?: Record; }; -class ValidateSignupRequestDto extends createZodDto(validateSignupRequestSchema) {} class SignupRequestDto extends createZodDto(signupRequestSchema) {} class AccountStatusRequestDto extends createZodDto(accountStatusRequestSchema) {} class RefreshTokenRequestDto extends createZodDto(refreshTokenRequestSchema) {} @@ -126,29 +123,12 @@ export class AuthController { FailedLoginThrottleGuard.applyRateLimitHeaders(req, res); } - @Public() - @Post("validate-signup") - @UseGuards(RateLimitGuard, SalesforceReadThrottleGuard) - @RateLimit({ limit: 20, ttl: 600 }) // 20 validations per 10 minutes per IP - async validateSignup(@Body() validateData: ValidateSignupRequestDto, @Req() req: Request) { - return this.authFacade.validateSignup(validateData, req); - } - @Public() @Get("health-check") async healthCheck() { return this.authFacade.healthCheck(); } - @Public() - @Post("signup-preflight") - @UseGuards(RateLimitGuard, SalesforceReadThrottleGuard) - @RateLimit({ limit: 20, ttl: 600 }) // 20 validations per 10 minutes per IP - @HttpCode(200) - async signupPreflight(@Body() signupData: SignupRequestDto) { - return this.authFacade.signupPreflight(signupData); - } - @Public() @Post("account-status") async accountStatus(@Body() body: AccountStatusRequestDto) { diff --git a/apps/bff/src/modules/billing/billing.controller.ts b/apps/bff/src/modules/billing/billing.controller.ts index 0d47487d..dc673365 100644 --- a/apps/bff/src/modules/billing/billing.controller.ts +++ b/apps/bff/src/modules/billing/billing.controller.ts @@ -14,18 +14,9 @@ import { invoiceSchema, invoiceSsoLinkSchema, invoiceSsoQuerySchema, - invoicePaymentLinkQuerySchema, } from "@customer-portal/domain/billing"; -import type { - PaymentMethodList, - PaymentGatewayList, - InvoicePaymentLink, -} from "@customer-portal/domain/payments"; -import { - paymentMethodListSchema, - paymentGatewayListSchema, - invoicePaymentLinkSchema, -} from "@customer-portal/domain/payments"; +import type { PaymentMethodList } from "@customer-portal/domain/payments"; +import { paymentMethodListSchema } from "@customer-portal/domain/payments"; class InvoiceListQueryDto extends createZodDto(invoiceListQuerySchema) {} class InvoiceIdParamDto extends createZodDto(invoiceIdParamSchema) {} @@ -33,10 +24,7 @@ class InvoiceListDto extends createZodDto(invoiceListSchema) {} class InvoiceDto extends createZodDto(invoiceSchema) {} class InvoiceSsoLinkDto extends createZodDto(invoiceSsoLinkSchema) {} class InvoiceSsoQueryDto extends createZodDto(invoiceSsoQuerySchema) {} -class InvoicePaymentLinkQueryDto extends createZodDto(invoicePaymentLinkQuerySchema) {} class PaymentMethodListDto extends createZodDto(paymentMethodListSchema) {} -class PaymentGatewayListDto extends createZodDto(paymentGatewayListSchema) {} -class InvoicePaymentLinkDto extends createZodDto(invoicePaymentLinkSchema) {} /** * Billing Controller @@ -69,12 +57,6 @@ export class BillingController { return this.whmcsPaymentService.getPaymentMethods(whmcsClientId, req.user.id); } - @Get("payment-gateways") - @ZodResponse({ description: "List payment gateways", type: PaymentGatewayListDto }) - async getPaymentGateways(): Promise { - return this.whmcsPaymentService.getPaymentGateways(); - } - @Post("payment-methods/refresh") @HttpCode(HttpStatus.OK) @ZodResponse({ description: "Refresh payment methods", type: PaymentMethodListDto }) @@ -117,28 +99,4 @@ export class BillingController { expiresAt: new Date(Date.now() + 60000).toISOString(), // 60 seconds per WHMCS spec }; } - - @Post(":id/payment-link") - @HttpCode(HttpStatus.OK) - @ZodResponse({ description: "Create invoice payment link", type: InvoicePaymentLinkDto }) - async createPaymentLink( - @Request() req: RequestWithUser, - @Param() params: InvoiceIdParamDto, - @Query() query: InvoicePaymentLinkQueryDto - ): Promise { - const whmcsClientId = await this.mappingsService.getWhmcsClientIdOrThrow(req.user.id); - - const ssoResult = await this.whmcsPaymentService.createPaymentSsoToken( - whmcsClientId, - params.id, - query.paymentMethodId, - query.gatewayName - ); - - return { - url: ssoResult.url, - expiresAt: ssoResult.expiresAt, - gatewayName: query.gatewayName, - }; - } } diff --git a/apps/bff/src/modules/users/users.controller.ts b/apps/bff/src/modules/users/users.controller.ts index 379544ad..8dcd601c 100644 --- a/apps/bff/src/modules/users/users.controller.ts +++ b/apps/bff/src/modules/users/users.controller.ts @@ -11,7 +11,6 @@ import { import { UsersFacade } from "./application/users.facade.js"; import { createZodDto, ZodResponse, ZodSerializerDto } from "nestjs-zod"; import { updateCustomerProfileRequestSchema } from "@customer-portal/domain/auth"; -import { dashboardSummarySchema } from "@customer-portal/domain/dashboard"; import { addressSchema, userSchema } from "@customer-portal/domain/customer"; import { bilingualAddressSchema } from "@customer-portal/domain/address"; import type { Address, User } from "@customer-portal/domain/customer"; @@ -24,7 +23,6 @@ class UpdateBilingualAddressDto extends createZodDto(bilingualAddressSchema) {} class UpdateCustomerProfileRequestDto extends createZodDto(updateCustomerProfileRequestSchema) {} class AddressDto extends createZodDto(addressSchema) {} class UserDto extends createZodDto(userSchema) {} -class DashboardSummaryDto extends createZodDto(dashboardSummarySchema) {} @Controller("me") @UseInterceptors(ClassSerializerInterceptor) @@ -48,16 +46,6 @@ export class UsersController { return this.usersFacade.getProfile(req.user.id); } - /** - * GET /me/summary - Get dashboard summary - */ - @UseGuards(SalesforceReadThrottleGuard) - @Get("summary") - @ZodResponse({ description: "Get dashboard summary", type: DashboardSummaryDto }) - async getSummary(@Req() req: RequestWithUser) { - return this.usersFacade.getUserSummary(req.user.id); - } - /** * GET /me/address - Get customer address only */ diff --git a/package.json b/package.json index 123d0ef7..ff012482 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "packageManager": "pnpm@10.25.0+sha512.5e82639027af37cf832061bcc6d639c219634488e0f2baebe785028a793de7b525ffcd3f7ff574f5e9860654e098fe852ba8ac5dd5cefe1767d23a020a92f501", "scripts": { - "dev": "./scripts/dev/manage.sh apps", + "dev": "pnpm domain:build && ./scripts/dev/manage.sh apps", "dev:all": "pnpm --filter @customer-portal/domain build && pnpm --parallel --filter @customer-portal/portal --filter @customer-portal/bff run dev", "dev:apps": "pnpm --parallel --filter @customer-portal/portal --filter @customer-portal/bff run dev", "domain:build": "pnpm --filter @customer-portal/domain build",