tambahannya
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import Elysia from "elysia";
|
||||
import Elysia, { t } from "elysia";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
|
||||
@@ -53,7 +53,7 @@ const LogsRoute = new Elysia({
|
||||
/**
|
||||
* GET /logs/app?lines=100&level=error
|
||||
*/
|
||||
.get("/app", async ({ query }) => {
|
||||
.get("/show", async ({ query }) => {
|
||||
const lines = query.lines ? Number(query.lines) : undefined;
|
||||
const level = query.level || undefined;
|
||||
|
||||
@@ -71,6 +71,27 @@ const LogsRoute = new Elysia({
|
||||
total: logs.length,
|
||||
data: logs,
|
||||
};
|
||||
}, {
|
||||
query: t.Object({
|
||||
lines: t.Optional(t.Number()),
|
||||
level: t.Optional(t.String()),
|
||||
}),
|
||||
detail: {
|
||||
summary: "Get logs",
|
||||
description: "Get logs from app.log",
|
||||
}
|
||||
})
|
||||
.post("/clear", async () => {
|
||||
await fs.rm(path.join(LOGS_PATH, "app.log"));
|
||||
return {
|
||||
success: true,
|
||||
message: "Log file cleared",
|
||||
};
|
||||
}, {
|
||||
detail: {
|
||||
summary: "Clear logs",
|
||||
description: "Clear logs from app.log",
|
||||
}
|
||||
});
|
||||
|
||||
export default LogsRoute;
|
||||
|
||||
Reference in New Issue
Block a user