removed notif legacy router

This commit is contained in:
user
2026-03-01 04:09:03 +02:00
parent 6b3ecc3aad
commit ca056b817d
3 changed files with 1 additions and 163 deletions

View File

@@ -1,12 +1,10 @@
import { notificationsRouter } from "@pkg/logic/domains/notifications/router";
import { usersRouter } from "@pkg/logic/domains/user/router";
import { twofaRouter } from "@pkg/logic/domains/2fa/router";
import { Hono } from "hono";
const baseRouter = new Hono()
.route("/users", usersRouter)
.route("/twofactor", twofaRouter)
.route("/notifications", notificationsRouter);
.route("/twofactor", twofaRouter);
export const apiBasePath = "/api/v1";

View File

@@ -1,160 +0,0 @@
import { bulkNotificationIdsSchema, getNotificationsSchema } from "./data";
import { getNotificationController } from "./controller";
import { sValidator } from "@hono/standard-validator";
import { HonoContext } from "@core/hono.helpers";
import { Hono } from "hono";
const nc = getNotificationController();
export const notificationsRouter = new Hono<HonoContext>()
.get("/", async (c) => {
const fctx = c.env.locals.fCtx;
const userId = c.env.locals.user.id;
const url = new URL(c.req.url);
const filters = {
userId,
isRead: url.searchParams.get("isRead")
? url.searchParams.get("isRead") === "true"
: undefined,
isArchived: url.searchParams.get("isArchived")
? url.searchParams.get("isArchived") === "true"
: undefined,
type: url.searchParams.get("type") || undefined,
category: url.searchParams.get("category") || undefined,
priority: url.searchParams.get("priority") || undefined,
search: url.searchParams.get("search") || undefined,
};
const pagination = {
page: parseInt(url.searchParams.get("page") || "1"),
pageSize: parseInt(url.searchParams.get("pageSize") || "20"),
sortBy: url.searchParams.get("sortBy") || "createdAt",
sortOrder: url.searchParams.get("sortOrder") || "desc",
};
const res = await nc.getNotifications(fctx, filters, pagination);
return c.json(
res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error },
res.isOk() ? 200 : 400,
);
})
.post(
"/get-notifications",
sValidator("json", getNotificationsSchema),
async (c) => {
const fctx = c.env.locals.fCtx;
const data = c.req.valid("json");
const res = await nc.getNotifications(fctx, data.filters, data.pagination);
return c.json(
res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error },
res.isOk() ? 200 : 400,
);
},
)
.put(
"/mark-read",
sValidator("json", bulkNotificationIdsSchema),
async (c) => {
const fctx = c.env.locals.fCtx;
const data = c.req.valid("json");
const userId = c.env.locals.user.id;
const res = await nc.markAsRead(fctx, [...data.notificationIds], userId);
return c.json(
res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error },
res.isOk() ? 200 : 400,
);
},
)
.put(
"/mark-unread",
sValidator("json", bulkNotificationIdsSchema),
async (c) => {
const fctx = c.env.locals.fCtx;
const data = c.req.valid("json");
const userId = c.env.locals.user.id;
const res = await nc.markAsUnread(fctx, [...data.notificationIds], userId);
return c.json(
res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error },
res.isOk() ? 200 : 400,
);
},
)
.put(
"/archive",
sValidator("json", bulkNotificationIdsSchema),
async (c) => {
const fctx = c.env.locals.fCtx;
const data = c.req.valid("json");
const userId = c.env.locals.user.id;
const res = await nc.archive(fctx, [...data.notificationIds], userId);
return c.json(
res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error },
res.isOk() ? 200 : 400,
);
},
)
.put(
"/unarchive",
sValidator("json", bulkNotificationIdsSchema),
async (c) => {
const fctx = c.env.locals.fCtx;
const data = c.req.valid("json");
const userId = c.env.locals.user.id;
const res = await nc.unarchive(fctx, [...data.notificationIds], userId);
return c.json(
res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error },
res.isOk() ? 200 : 400,
);
},
)
.delete(
"/delete",
sValidator("json", bulkNotificationIdsSchema),
async (c) => {
const fctx = c.env.locals.fCtx;
const data = c.req.valid("json");
const userId = c.env.locals.user.id;
const res = await nc.deleteNotifications(fctx, [...data.notificationIds], userId);
return c.json(
res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error },
res.isOk() ? 200 : 400,
);
},
)
.put("/mark-all-read", async (c) => {
const fctx = c.env.locals.fCtx;
const userId = c.env.locals.user.id;
const res = await nc.markAllAsRead(fctx, userId);
return c.json(
res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error },
res.isOk() ? 200 : 400,
);
})
.get("/unread-count", async (c) => {
const fctx = c.env.locals.fCtx;
const userId = c.env.locals.user.id;
const res = await nc.getUnreadCount(fctx, userId);
return c.json(
res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error },
res.isOk() ? 200 : 400,
);
});