Add server

This commit is contained in:
2023-05-25 11:21:37 +08:00
parent 38e970dc7d
commit 614f05fc22
8 changed files with 202 additions and 8 deletions

13
routes/api/task/list.ts Normal file
View File

@@ -0,0 +1,13 @@
import { Handlers } from "$fresh/server.ts";
import { get_task_manager } from "../../../server.ts";
import { Task } from "../../../task.ts";
export const handler: Handlers<Task[]> = {
async GET(_, _ctx) {
const t = get_task_manager();
const tasks = await t.db.get_tasks_by_pid(Deno.pid);
return new Response(JSON.stringify(tasks), {
headers: { "Content-Type": "application/json" },
});
},
};