👔 (comment bg) add command background helper

add command background helper and implemented on edit user service
This commit is contained in:
unknown
2025-06-29 05:23:10 +07:00
parent 2f53060659
commit fea545f0de
3 changed files with 38 additions and 7 deletions

View File

@ -0,0 +1,21 @@
import { saveFile } from "..";
import { AppError } from "../../../error/instances/app";
export const saveCommentBackground = async (file: File): Promise<string> => {
if (Array.isArray(file)) {
throw new AppError(415, "Can't upload more than 1 file");
}
const allowedTypes = ["image/png", "image/jpeg", "image/webp"];
if (!allowedTypes.includes(file.type)) {
throw new AppError(
415,
"Unsupported Media Type. File must be in .jpg, .png, or .webp format"
);
}
return await saveFile(file, {
folder: "comment-backgorund",
prefix: "cmnt-bg-",
});
};