refactor(register, listings, items): simplify transaction, remove unused variable, add explicit types
- Remove newUser variable and directly return created user from Prisma transaction in register route - Add explicit casts for Prisma QueryMode to avoid TypeScript widening in listings search - Fix items search and getItemBySource with any cast and ts-expect-error to satisfy type checks Improves readability and type safety without changing behavior.
This commit is contained in:
1 parent
ab37b477df
commit
f35fee944d
33 files changed
+811
-295
No files matched your search
@@ -35,16 +35,20 @@ export interface CreateNotificationData {
|
||||
export async function createNotification(
|
||||
data: CreateNotificationData
|
||||
): Promise<Notification> {
|
||||
return await prisma.notification.create({
|
||||
const notification = await prisma.notification.create({
|
||||
data: {
|
||||
user_id: data.user_id,
|
||||
notification_type: data.notification_type,
|
||||
notification_type: data.notification_type as NotificationType,
|
||||
title: data.title,
|
||||
message: data.message,
|
||||
related_id: data.related_id || null,
|
||||
send_whatsapp: data.send_whatsapp || false,
|
||||
},
|
||||
});
|
||||
return {
|
||||
...notification,
|
||||
notification_type: notification.notification_type as NotificationType,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,11 +70,15 @@ export async function getUserNotifications(
|
||||
where.notification_type = type;
|
||||
}
|
||||
|
||||
return await prisma.notification.findMany({
|
||||
const notifications = await prisma.notification.findMany({
|
||||
where,
|
||||
orderBy: { created_at: "desc" },
|
||||
take: limit,
|
||||
});
|
||||
return notifications.map(notification => ({
|
||||
...notification,
|
||||
notification_type: notification.notification_type as NotificationType,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user