Fix/missing environment variable type#7 #15
@@ -130,7 +130,7 @@ const get_single_order_from_db = async (req: Request) => {
|
||||
|
||||
const create_order_into_db = async (req: Request) => {
|
||||
const payload = req?.body;
|
||||
console.log(payload);
|
||||
|
||||
payload.status = "INITIATED";
|
||||
payload.paymentType = "COD";
|
||||
|
||||
@@ -153,7 +153,6 @@ const create_order_into_db = async (req: Request) => {
|
||||
const update_order_into_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const user = req.user;
|
||||
console.log(user);
|
||||
if (user?.role !== "ADMIN") {
|
||||
throw new AppError("You are not authorized to perform this action", 403);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ const update_profile_into_db = async (req: Request) => {
|
||||
const user = req?.user as JwtPayloadType;
|
||||
const payload = req?.body;
|
||||
const file = req?.file;
|
||||
console.log(payload);
|
||||
// check file and upload to cloud
|
||||
if (file) {
|
||||
const cloudRes = await uploadCloud(file);
|
||||
|
||||
@@ -1,58 +1,63 @@
|
||||
|
||||
import { Request } from "express";
|
||||
import { prisma } from "../../lib/prisma.js";
|
||||
import paginationHelper from "../../utils/pagination_helper.js";
|
||||
|
||||
const get_all_users_from_db = async (req: Request) => {
|
||||
const {page,skip,limit}=paginationHelper(req.query);
|
||||
|
||||
const { page, skip, limit } = paginationHelper(req.query);
|
||||
const search = req.query.search as string;
|
||||
|
||||
const andCondition = {} as any;
|
||||
if (search) {
|
||||
andCondition.shopName = {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
};
|
||||
}
|
||||
// define your own login here
|
||||
const result = await prisma.profile.findMany({
|
||||
take:limit,
|
||||
take: limit,
|
||||
skip,
|
||||
select:{
|
||||
account:{
|
||||
select:{
|
||||
isSubscribe:true,
|
||||
email:true,
|
||||
|
||||
}
|
||||
where: andCondition,
|
||||
select: {
|
||||
account: {
|
||||
select: {
|
||||
isSubscribe: true,
|
||||
email: true,
|
||||
},
|
||||
},
|
||||
shopName:true,
|
||||
id:true,
|
||||
status:true
|
||||
|
||||
}
|
||||
shopName: true,
|
||||
id: true,
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
const usersCount = await prisma.profile.count();
|
||||
return{ result,usersCount,page,limit,skip};
|
||||
return { result, usersCount, page, limit, skip };
|
||||
};
|
||||
|
||||
const get_single_users_from_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const { id } = req.params as { id: string };
|
||||
const result = await prisma.account.findUnique({where:{id}});
|
||||
const result = await prisma.profile.findUnique({ where: { id } });
|
||||
return result;
|
||||
};
|
||||
|
||||
const create_users_into_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const result = await prisma.account.create({data:req.body});
|
||||
const result = await prisma.account.create({ data: req.body });
|
||||
return result;
|
||||
};
|
||||
|
||||
const update_users_into_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const { id } = req.params as { id: string };
|
||||
const result = await prisma.account.update({where:{id},data:req.body});
|
||||
const result = await prisma.account.update({ where: { id }, data: req.body });
|
||||
return result;
|
||||
};
|
||||
|
||||
const delete_users_from_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const { id } = req.params as { id: string };
|
||||
const result = await prisma.account.delete({where:{id}});
|
||||
const result = await prisma.account.delete({ where: { id } });
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -63,4 +68,3 @@ export const users_service = {
|
||||
update_users_into_db,
|
||||
delete_users_from_db,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
export const usersSwaggerDocs = {
|
||||
export const usersSwaggerDocs = {
|
||||
"/api/users": {
|
||||
post: {
|
||||
tags: ["users"],
|
||||
@@ -35,6 +34,12 @@
|
||||
required: false,
|
||||
schema: { type: "number" },
|
||||
},
|
||||
{
|
||||
name: "search",
|
||||
in: "query",
|
||||
required: false,
|
||||
schema: { type: "string" },
|
||||
},
|
||||
],
|
||||
responses: {
|
||||
200: { description: "users fetched successfully" },
|
||||
@@ -105,6 +110,3 @@
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user