Files
lstV2/server/services/notifications/routes/getNotifications.ts

46 lines
1.4 KiB
TypeScript

// an external way to creating logs
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
//import { apiHit } from "../../../globalUtils/apiHits.js";
import { responses } from "../../../globalUtils/routeDefs/responses.js";
import { getNotifications } from "../controller/getNotifications.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";
import { apiHit } from "../../../globalUtils/apiHits.js";
const app = new OpenAPIHono({ strict: false });
app.openapi(
createRoute({
tags: ["notify"],
summary: "Gets notifications.",
method: "get",
path: "/notifications",
// description:
// "This might be a temp soltuin during the transtion between versions",
responses: responses(),
}),
async (c: any) => {
apiHit(c, { endpoint: "/notifications" });
const { data, error } = await tryCatch(getNotifications());
if (error) {
return c.json(
{
success: false,
message: "There was an error clearing the log.",
data: error,
},
400
);
}
return c.json(
{
success: data?.success,
message: data?.message,
data: data?.data,
},
200
);
}
);
export default app;