refactor: remove unused DTOs and guards from auth and billing controllers
This commit is contained in:
parent
26502b4356
commit
7bcd7fa10d
@ -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<Request, "cookies"> & {
|
||||
cookies?: Record<string, CookieValue>;
|
||||
};
|
||||
|
||||
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) {
|
||||
|
||||
@ -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<PaymentGatewayList> {
|
||||
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<InvoicePaymentLink> {
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
*/
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user