el.xwx.moe/pages/api/v1/dashboard/index.ts

23 lines
756 B
TypeScript
Raw Normal View History

2023-10-23 09:45:48 -05:00
import type { NextApiRequest, NextApiResponse } from "next";
import { LinkRequestQuery } from "@/types/global";
import getDashboardData from "@/lib/api/controllers/dashboard/getDashboardData";
import verifyUser from "@/lib/api/verifyUser";
2023-10-23 09:45:48 -05:00
2024-06-26 16:59:23 -05:00
export default async function dashboard(
req: NextApiRequest,
res: NextApiResponse
) {
const user = await verifyUser({ req, res });
if (!user) return;
2023-10-23 09:45:48 -05:00
if (req.method === "GET") {
const convertedData: LinkRequestQuery = {
sort: Number(req.query.sort as string),
cursor: req.query.cursor ? Number(req.query.cursor as string) : undefined,
};
2023-11-02 13:59:31 -05:00
const links = await getDashboardData(user.id, convertedData);
2023-10-23 09:45:48 -05:00
return res.status(links.status).json({ response: links.response });
}
}