MCPcopy Create free account
hub / github.com/ShipSecAI/studio / ShipSecApiClient

Class ShipSecApiClient

packages/backend-client/src/api-client.ts:34–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 * Type-safe client for the ShipSec backend API
33 */
34export class ShipSecApiClient {
35 private client: ReturnType<typeof createClient<paths>>;
36 private baseUrl: string;
37
38 constructor(config: ClientConfig = {}) {
39 this.baseUrl = config.baseUrl || 'http://localhost:3211';
40
41 this.client = createClient<paths>({
42 baseUrl: this.baseUrl,
43 headers: {
44 'Content-Type': 'application/json',
45 ...config.headers,
46 },
47 });
48
49 if (config.middleware) {
50 const middlewares = Array.isArray(config.middleware)
51 ? config.middleware
52 : [config.middleware];
53 for (const mw of middlewares) {
54 this.client.use(mw);
55 }
56 }
57 }
58
59 getBaseUrl(): string {
60 return this.baseUrl;
61 }
62
63 buildUrl(path: string): string {
64 const normalized = path.startsWith('/') ? path : `/${path}`;
65 return new URL(normalized, this.baseUrl).toString();
66 }
67
68 /**
69 * Add middleware to the client
70 */
71 use(middleware: Middleware) {
72 this.client.use(middleware);
73 }
74
75 // ===== Health =====
76
77 async health() {
78 return this.client.GET('/api/v1/health');
79 }
80
81 // ===== Workflows =====
82
83 async listWorkflows() {
84 return this.client.GET('/api/v1/workflows');
85 }
86
87 async getWorkflow(id: string) {
88 return this.client.GET('/api/v1/workflows/{id}', {
89 params: { path: { id } },
90 });
91 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected