diff --git a/packages/fetch/package.json b/packages/fetch/package.json deleted file mode 100644 index d5bd6971..00000000 --- a/packages/fetch/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@multica/fetch", - "version": "0.1.0", - "private": true, - "type": "module", - "exports": { - ".": "./src/index.ts", - "./*": "./src/*.ts" - }, - "devDependencies": { - "typescript": "catalog:" - } -} diff --git a/packages/fetch/src/config.ts b/packages/fetch/src/config.ts deleted file mode 100644 index ff2abde9..00000000 --- a/packages/fetch/src/config.ts +++ /dev/null @@ -1,15 +0,0 @@ -let consoleUrl = "http://localhost:4000" -let gatewayUrl = "http://localhost:3000" - -export function setConfig(config: { consoleUrl?: string; gatewayUrl?: string }) { - if (config.consoleUrl) consoleUrl = config.consoleUrl - if (config.gatewayUrl) gatewayUrl = config.gatewayUrl -} - -export function getConsoleUrl(): string { - return consoleUrl -} - -export function getGatewayUrl(): string { - return gatewayUrl -} diff --git a/packages/fetch/src/http-client.ts b/packages/fetch/src/http-client.ts deleted file mode 100644 index e9564d09..00000000 --- a/packages/fetch/src/http-client.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { getConsoleUrl } from "./config" - -export class HttpError extends Error { - constructor( - public status: number, - public statusText: string, - ) { - super(`HTTP ${status}: ${statusText}`) - } -} - -async function request(method: string, path: string, body?: unknown): Promise { - const res = await fetch(`${getConsoleUrl()}${path}`, { - method, - headers: body ? { "Content-Type": "application/json" } : undefined, - body: body ? JSON.stringify(body) : undefined, - }) - if (!res.ok) throw new HttpError(res.status, res.statusText) - return res.json() -} - -/** Console REST API */ -export const consoleApi = { - get: (path: string) => request("GET", path), - post: (path: string, body?: unknown) => request("POST", path, body), - put: (path: string, body: unknown) => request("PUT", path, body), - delete: (path: string) => request("DELETE", path), -} diff --git a/packages/fetch/src/index.ts b/packages/fetch/src/index.ts deleted file mode 100644 index 8500fa04..00000000 --- a/packages/fetch/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { setConfig, getConsoleUrl, getGatewayUrl } from "./config" -export { consoleApi, HttpError } from "./http-client" diff --git a/packages/fetch/tsconfig.json b/packages/fetch/tsconfig.json deleted file mode 100644 index c1103210..00000000 --- a/packages/fetch/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "bundler", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "declaration": true, - "outDir": "./dist", - "rootDir": "./src" - }, - "include": ["src"] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c576814f..0fc53daf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -258,12 +258,6 @@ importers: specifier: 'catalog:' version: 5.9.3 - packages/fetch: - devDependencies: - typescript: - specifier: 'catalog:' - version: 5.9.3 - packages/sdk: dependencies: socket.io-client: