refactor(old app): login migration to new app
This commit is contained in:
@@ -1,31 +1,33 @@
|
||||
// an external way to creating logs
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { getAllJobs } from "../utils/processNotifications.js";
|
||||
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { authMiddleware } from "../../auth/middleware/authMiddleware.js";
|
||||
import hasCorrectRole from "../../auth/middleware/roleCheck.js";
|
||||
import { getAllJobs } from "../utils/processNotifications.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["server"],
|
||||
summary: "Returns current active notifications.",
|
||||
method: "get",
|
||||
path: "/activenotifications",
|
||||
//middleware: authMiddleware,
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
apiHit(c, { endpoint: "/activenotifications" });
|
||||
const jobs = getAllJobs();
|
||||
return c.json({
|
||||
success: true,
|
||||
message:
|
||||
jobs.length === 0
|
||||
? "There are no active Notifications Currently."
|
||||
: "Current Active notifications",
|
||||
data: jobs,
|
||||
});
|
||||
}
|
||||
createRoute({
|
||||
tags: ["server"],
|
||||
summary: "Returns current active notifications.",
|
||||
method: "get",
|
||||
path: "/activenotifications",
|
||||
middleware: [authMiddleware, hasCorrectRole(["systemAdmin"], "admin")],
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
apiHit(c, { endpoint: "/activenotifications" });
|
||||
const jobs = getAllJobs();
|
||||
return c.json({
|
||||
success: true,
|
||||
message:
|
||||
jobs.length === 0
|
||||
? "There are no active Notifications Currently."
|
||||
: "Current Active notifications",
|
||||
data: jobs,
|
||||
});
|
||||
},
|
||||
);
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user