feat: add more helper function
This commit is contained in:
parent
771f1a1c58
commit
f9cc39522c
2 changed files with 16 additions and 0 deletions
10
src/utils/error.ts
Normal file
10
src/utils/error.ts
Normal 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`,
|
||||
);
|
||||
}
|
||||
|
|
@ -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 || ""}`,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue