feat: add terminal & wake pc

This commit is contained in:
2024-03-16 10:14:17 +07:00
parent 1e8252d9da
commit 5e8a3c88a2
21 changed files with 782 additions and 21 deletions
+3 -1
View File
@@ -2,13 +2,15 @@ import { Hono } from "hono";
import auth from "./auth";
import system from "./system";
import _process from "./process";
import apps from "./apps";
import { authMiddleware } from "../lib/jwt";
const routes = new Hono()
.route("/auth", auth)
.use(authMiddleware)
.route("/system", system)
.route("/process", _process);
.route("/process", _process)
.route("/apps", apps);
export type AppType = typeof routes;
+22
View File
@@ -0,0 +1,22 @@
import { Hono } from "hono";
import wol from "wol";
import { HTTPException } from "hono/http-exception";
const route = new Hono().post("/wakepc", async (c) => {
const { PC_MAC_ADDR } = process.env;
try {
await new Promise((resolve, reject) => {
wol.wake(PC_MAC_ADDR || "", (err: any, res: any) =>
err ? reject(err) : resolve(res)
);
});
} catch (err) {
console.log(err);
throw new HTTPException(400, { message: "Cannot wake pc up!" });
}
return c.json({ message: "waking up..." });
});
export default route;