working run api calls

This commit is contained in:
2026-02-08 14:15:16 +01:00
parent 6f418661c4
commit f944de31e2
4 changed files with 171 additions and 1 deletions
+32 -1
View File
@@ -1,3 +1,5 @@
import axios from "axios";
var cookies: string | undefined;
export function getCookies(): string | undefined {
@@ -7,6 +9,35 @@ export function setCookies(c: string) {
cookies = c;
}
export async function submitRun() {}
export async function addRun(problem: string, mode: string): Promise<string> {
return (
await axios.put(
"http://localhost:3000/api/run",
{
problem,
category: mode,
},
{
headers: {
Cookie: cookies,
},
},
)
).data.runId;
}
export async function submitRun(runId: string) {
await axios.post(
"http://localhost:3000/api/run",
{
runId,
},
{
headers: {
Cookie: cookies,
},
},
);
}
export async function addRunMoves() {}
+6
View File
@@ -1,9 +1,11 @@
import * as vscode from "vscode";
import { addRun, submitRun } from "./client";
export var currentRun: {
interval: NodeJS.Timeout;
problemId: string;
start: Date;
id: string;
} | null = null;
export async function startRun(
@@ -38,7 +40,10 @@ export async function startRun(
let start = Date.now();
const runId = await addRun(problemId, mode);
currentRun = {
id: runId,
problemId,
start: new Date(),
interval: setInterval(() => {
@@ -60,6 +65,7 @@ export async function startRun(
export async function stopRun() {
if (currentRun) {
clearTimeout(currentRun.interval);
submitRun(currentRun.id);
currentRun = null;
}