init: init project
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { Request } from "express";
|
||||
import uploadCloud from "../../utils/cloudinary";
|
||||
import { prisma } from "../../lib/prisma";
|
||||
import { JwtPayloadType } from "../../utils/JWT";
|
||||
|
||||
const update_profile_into_db = async (req: Request) => {
|
||||
const user = req?.user as JwtPayloadType;
|
||||
const payload = req?.body;
|
||||
const file = req?.file;
|
||||
// check file and upload to cloud
|
||||
if (file) {
|
||||
const cloudRes = await uploadCloud(file);
|
||||
payload.profilePhoto = cloudRes?.secure_url;
|
||||
}
|
||||
const result = await prisma.profile.update({
|
||||
where: {
|
||||
accountId: user.accountId as string,
|
||||
},
|
||||
data: payload,
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
export const profile_service = {
|
||||
update_profile_into_db,
|
||||
};
|
||||
Reference in New Issue
Block a user