feat: add more helper function

This commit is contained in:
Methapon Metanipat 2024-09-10 14:19:16 +07:00
parent 771f1a1c58
commit f9cc39522c
2 changed files with 16 additions and 0 deletions

10
src/utils/error.ts Normal file
View file

@ -0,0 +1,10 @@
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
export function throwRelationError(name: string) {
throw new HttpError(
HttpStatus.BAD_REQUEST,
`${name} cannot be found.`,
`relation${name.replaceAll(" ", "")}NotFound`,
);
}

View file

@ -55,4 +55,10 @@ export const fileLocation = {
customer: {
img: (customerId: string, name?: string) => `customer/img-${customerId}/${name || ""}`,
},
product: {
img: (productId: string, name?: string) => `product/img-${productId}/${name || ""}`,
},
service: {
img: (serviceId: string, name?: string) => `service/img-${serviceId}/${name || ""}`,
},
};