removed notif legacy router
This commit is contained in:
@@ -1,12 +1,10 @@
|
|||||||
import { notificationsRouter } from "@pkg/logic/domains/notifications/router";
|
|
||||||
import { usersRouter } from "@pkg/logic/domains/user/router";
|
import { usersRouter } from "@pkg/logic/domains/user/router";
|
||||||
import { twofaRouter } from "@pkg/logic/domains/2fa/router";
|
import { twofaRouter } from "@pkg/logic/domains/2fa/router";
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
|
||||||
const baseRouter = new Hono()
|
const baseRouter = new Hono()
|
||||||
.route("/users", usersRouter)
|
.route("/users", usersRouter)
|
||||||
.route("/twofactor", twofaRouter)
|
.route("/twofactor", twofaRouter);
|
||||||
.route("/notifications", notificationsRouter);
|
|
||||||
|
|
||||||
export const apiBasePath = "/api/v1";
|
export const apiBasePath = "/api/v1";
|
||||||
|
|
||||||
|
|||||||
0
apps/main/src/lib/domains/security/twofa.remote.ts
Normal file
0
apps/main/src/lib/domains/security/twofa.remote.ts
Normal 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,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user