test(notification): added framework for managment tab
This commit is contained in:
30
server/services/notifications/controller/getNotifications.ts
Normal file
30
server/services/notifications/controller/getNotifications.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { and, desc, eq, gte, inArray, lte, sql } from "drizzle-orm";
|
||||
import { db } from "../../../../database/dbclient.js";
|
||||
import { logs } from "../../../../database/schema/logs.js";
|
||||
import { createLog } from "../../logger/logger.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { notifications } from "../../../../database/schema/notifications.js";
|
||||
|
||||
export const getNotifications = async () => {
|
||||
const { data, error } = await tryCatch(db.select().from(notifications));
|
||||
|
||||
if (error) {
|
||||
createLog(
|
||||
"error",
|
||||
"notify",
|
||||
"notify",
|
||||
`Error getting notifications: ${error}`
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
message: "Error getting notifications.",
|
||||
data: error,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
sucess: true,
|
||||
message: "Current notifications.",
|
||||
data: data,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user