refactor: migrate to tsup for builds and update tsconfigs fix: update error handling and validation in payment service chore: update package scripts and dependencies docs: update README and env examples
21 lines
684 B
TypeScript
21 lines
684 B
TypeScript
import { AppError, createAppError } from "@repo/exceptions";
|
|
|
|
export enum PaymentErrorCode {
|
|
PAYMENT_NOT_FOUND = "PAYMENT_NOT_FOUND",
|
|
PAYMENT_ALREADY_PROCESSED = "PAYMENT_ALREADY_PROCESSED",
|
|
}
|
|
|
|
export type PaymentError = AppError<PaymentErrorCode>;
|
|
|
|
export const paymentNotFound = (paymentId: string): PaymentError =>
|
|
createAppError<PaymentErrorCode>(
|
|
PaymentErrorCode.PAYMENT_NOT_FOUND,
|
|
`Payment with id ${paymentId} not found`,
|
|
) as PaymentError;
|
|
|
|
export const paymentAlreadyProcessed = (paymentId: string): PaymentError =>
|
|
createAppError(
|
|
PaymentErrorCode.PAYMENT_ALREADY_PROCESSED,
|
|
`Payment ${paymentId} has already been processed`,
|
|
) as PaymentError;
|