36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
// an external way to creating logs
|
|
//@ts-nocheck
|
|
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
|
import {apiHit} from "../../../globalUtils/apiHits.js";
|
|
import {responses} from "../../../globalUtils/routeDefs/responses.js";
|
|
import {createLog} from "../logger.js";
|
|
import {getLogs} from "../controller/getLogs.js";
|
|
import {streamLogs} from "../controller/streamLogs.js";
|
|
import {streamSSE} from "hono/streaming";
|
|
|
|
const app = new OpenAPIHono({strict: false});
|
|
|
|
app.openapi(
|
|
createRoute({
|
|
tags: ["server:logger"],
|
|
summary: "Streams the logs to the frontend.",
|
|
method: "get",
|
|
path: "/logs/stream",
|
|
description: "This should only be used on the event you need to monitor logs.",
|
|
|
|
responses: {
|
|
200: {
|
|
content: {
|
|
"application/json": {schema: z.object({message: z.string().optional()})},
|
|
},
|
|
description: "Response message",
|
|
},
|
|
},
|
|
}),
|
|
async (c) => {
|
|
apiHit(c, {endpoint: `api/logger/logs`});
|
|
return streamLogs(c);
|
|
}
|
|
);
|
|
export default app;
|