feat(logger): logger service created with its endpoints

This commit is contained in:
2025-03-19 17:15:33 -05:00
parent c9aa41ab00
commit 7ec5c5beb0
7 changed files with 256 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import {OpenAPIHono} from "@hono/zod-openapi";
// routes
import clearLog from "./routes/clearLog.js";
import {db} from "../../../database/dbclient.js";
import {settings} from "../../../database/schema/settings.js";
import {logCleanup} from "./controller/logCleanup.js";
import createNewLog from "./routes/createLog.js";
import getLogs from "./routes/getLogs.js";
const app = new OpenAPIHono();
const routes = [clearLog, createNewLog, getLogs] as const;
const setting = await db.select().from(settings);
const appRoutes = routes.forEach((route) => {
app.route("/logger", route);
});
app.all("/logger/*", (c) => {
return c.json({success: false, message: "You have encounters a log route that dose not exist."});
});
// run the clean up job ones on server restart/crash/update and then once a date
logCleanup();
setInterval(async () => {
logCleanup();
}, 60 * 1000 * 60 * 24);
export default app;