Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
c8231d6
1
Parent(s):
5dfc565
add endpoint to list pending videos
Browse files- src/index.mts +16 -0
src/index.mts
CHANGED
@@ -10,6 +10,7 @@ import { getTask } from "./scheduler/getTask.mts"
|
|
10 |
import { main } from "./main.mts"
|
11 |
import { completedFilesDirFilePath } from "./config.mts"
|
12 |
import { deleteTask } from "./scheduler/deleteTask.mts"
|
|
|
13 |
|
14 |
main()
|
15 |
|
@@ -57,6 +58,21 @@ app.post("/", async (req, res) => {
|
|
57 |
}
|
58 |
})
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
app.get("/:id", async (req, res) => {
|
61 |
try {
|
62 |
const task = await getTask(req.params.id)
|
|
|
10 |
import { main } from "./main.mts"
|
11 |
import { completedFilesDirFilePath } from "./config.mts"
|
12 |
import { deleteTask } from "./scheduler/deleteTask.mts"
|
13 |
+
import { getPendingTasks } from "./scheduler/getPendingTasks.mts"
|
14 |
|
15 |
main()
|
16 |
|
|
|
58 |
}
|
59 |
})
|
60 |
|
61 |
+
// get all pending tasks
|
62 |
+
app.get("/", async (req, res) => {
|
63 |
+
try {
|
64 |
+
const tasks = await getPendingTasks()
|
65 |
+
res.status(200)
|
66 |
+
res.write(JSON.stringify(tasks, null, 2))
|
67 |
+
res.end()
|
68 |
+
} catch (err) {
|
69 |
+
console.error(err)
|
70 |
+
res.status(500)
|
71 |
+
res.write(JSON.stringify({ error: "couldn't get the tasks" }))
|
72 |
+
res.end()
|
73 |
+
}
|
74 |
+
})
|
75 |
+
|
76 |
app.get("/:id", async (req, res) => {
|
77 |
try {
|
78 |
const task = await getTask(req.params.id)
|