31 lines
913 B
TypeScript
31 lines
913 B
TypeScript
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;
|