Skip to content

Commit 50c535b

Browse files
committed
edited zustand stores and lib/api.ts file
1 parent 83f1324 commit 50c535b

8 files changed

Lines changed: 45 additions & 7 deletions

File tree

client/src/lib/api.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const BASE = import.meta.env.VITE_API_BASE ?? "http://localhost:3333/api";
2+
3+
async function request<T>(path: string, opts: RequestInit = {}): Promise<T> {
4+
const res = await fetch(`${BASE}${path}`, {
5+
headers: { "Content-Type": "application/json" },
6+
credentials: "include",
7+
...opts,
8+
});
9+
const data = await res.json().catch(() => ({}));
10+
if (!res.ok) throw new Error(data?.error || res.statusText);
11+
return data as T;
12+
}
13+
14+
export const api = {
15+
listRepos: () => request<{ repos: string[] }>("/mcp/repos"),
16+
listBranches: (repo: string) => request<{ branches: string[] }>(`/mcp/repos/${encodeURIComponent(repo)}/branches`),
17+
createPipeline: (payload: any) => request("/mcp/pipeline", { method: "POST", body: JSON.stringify(payload) }),
18+
listAwsRoles: () => request<{ roles: string[] }>("/mcp/oidc/roles"),
19+
openPr: (payload: any) => request("/mcp/pull-request", { method: "POST", body: JSON.stringify(payload) }),
20+
getConnections: (repo: string) => request(`/mcp/config/connections?repo=${encodeURIComponent(repo)}`),
21+
getSecretPresence: (repo: string, env: string) => request(`/mcp/config/secrets?repo=${encodeURIComponent(repo)}&env=${env}`),
22+
setSecret: (body: any) => request("/mcp/config/secret", { method: "POST", body: JSON.stringify(body) }),
23+
runPreflight: (body: any) => request("/mcp/config/preflight", { method: "POST", body: JSON.stringify(body) }),
24+
startDeploy: (body: any) => request("/mcp/deploy/start", { method: "POST", body: JSON.stringify(body) }),
25+
streamJob(jobId: string, onEvent: (e: any) => void) {
26+
const es = new EventSource(`${BASE}/mcp/jobs/${jobId}/events`, { withCredentials: true });
27+
es.onmessage = (evt) => onEvent(JSON.parse(evt.data));
28+
es.onerror = () => es.close();
29+
return () => es.close();
30+
},
31+
};
32+

client/src/pages/ConnectPage.tsx

Whitespace-only changes.

client/src/store/useConfigStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { create } from "zustand";
2-
import { api } from "@/lib/api";
2+
import { api } from "../lib/api";
33

44
type EnvName = "dev" | "staging" | "prod";
55
type SecretRef = { key: string; present: boolean };

client/src/store/useDeployStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { create } from "zustand";
2-
import { api } from "@/lib/api";
2+
import { api } from "../lib/api";
33

44
type JobEvent = { ts: string; level: "info" | "warn" | "error"; msg: string };
55

client/src/store/usePipelineStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { create } from "zustand";
2-
import { api } from "@/lib/api";
2+
import { api } from "../lib/api";
33
import type { McpPipeline } from "@/types/mcp";
44

55
type Stage = "build" | "test" | "deploy";

client/src/store/useRepoStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { create } from "zustand";
22
import { persist, createJSONStorage } from "zustand/middleware";
3-
import { api } from "@/lib/api";
3+
import { api } from "../lib/api";
44

55
//typescript friendly typing here for properties and functions we want our data to have
66
type RepoState = {

client/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
"references": [
44
{ "path": "./tsconfig.app.json" },
55
{ "path": "./tsconfig.node.json" }
6-
]
6+
],
7+
"compilerOptions": {
8+
"baseUrl": ".",
9+
"paths": {
10+
"@/*": ["src/*"]
711
}

client/vite.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
33

4-
// https://vite.dev/config/
54
export default defineConfig({
65
plugins: [react()],
7-
})
6+
resolve: { alias: { "@": path.resolve(__dirname, "src") } },
7+
});
8+
9+
import path from "path";

0 commit comments

Comments
 (0)