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,44 @@
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
import {apiHit} from "../../../globalUtils/apiHits.js";
import {responses} from "../../../globalUtils/routeDefs/responses.js";
import {clearLog} from "../controller/clearLog.js";
const app = new OpenAPIHono({strict: false});
const ParamsSchema = z.object({
id: z
.string()
.min(3)
.openapi({
param: {
name: "id",
in: "path",
},
example: "1212121",
}),
});
app.openapi(
createRoute({
tags: ["server:logger"],
summary: "Marks the select log id as cleared out.",
method: "patch",
path: "/logs/{id}",
request: {
params: ParamsSchema,
},
responses: responses(),
}),
async (c) => {
const {id} = c.req.valid("param");
//const body = await c.req.json();
// make sure we have a vaid user being accessed thats really logged in
apiHit(c, {endpoint: `api/logger/logs/id`});
try {
const clear = await clearLog(id);
return c.json({success: clear.success, message: clear.message, data: []}, 200);
} catch (error) {
return c.json({success: false, message: "There was an error clearing the log.", data: error}, 400);
}
}
);
export default app;