From 689dd3b49adb88bbae13714275d2b4800ce087e1 Mon Sep 17 00:00:00 2001 From: poswalsameer Date: Tue, 10 Dec 2024 19:10:31 +0530 Subject: [PATCH] deleted extra unnecessary files in the lib folder --- apps/platform/src/lib/api-client.ts | 93 ---------------------- apps/platform/src/lib/workspace-storage.ts | 30 ------- 2 files changed, 123 deletions(-) delete mode 100644 apps/platform/src/lib/api-client.ts delete mode 100644 apps/platform/src/lib/workspace-storage.ts diff --git a/apps/platform/src/lib/api-client.ts b/apps/platform/src/lib/api-client.ts deleted file mode 100644 index 410f1864..00000000 --- a/apps/platform/src/lib/api-client.ts +++ /dev/null @@ -1,93 +0,0 @@ -interface ErrorWithResponse extends Error { - status: number - response: Record -} - -class APIClient { - private baseUrl: string - constructor(baseUrl: string) { - this.baseUrl = baseUrl - } - - async request(url: string, options: RequestInit): Promise { - const response = await fetch(`${this.baseUrl}${url}`, options) - if (!response.ok) { - const error = new Error(response.statusText) as ErrorWithResponse - error.status = response.status - error.response = (await response.json()) as Record // Add type annotation here - throw error - } - return response.json() as Promise - } - - /** - * Sends a GET request to the specified URL and returns a Promise that resolves to the response data. - * @param url - The URL to send the GET request to. - * @returns A Promise that resolves to the response data. - */ - get(url: string): Promise { - return this.request(url, { - method: 'GET', - headers: { - 'Content-Type': 'application/json' - }, - credentials: 'include' - }) - } - - /** - * Sends a POST request to the specified URL with the provided data. - * - * @param url - The URL to send the request to. - * @param data - The data to send in the request body. - * @returns A Promise that resolves to the response data. - */ - post(url: string, data: Record): Promise { - return this.request(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data), - credentials: 'include' - }) - } - - /** - * Sends a PUT request to the specified URL with the provided data. - * - * @param url - The URL to send the request to. - * @param data - The data to be sent in the request body. - * @returns A Promise that resolves to the response data. - */ - put(url: string, data: Record): Promise { - return this.request(url, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data), - credentials: 'include' - }) - } - - /** - * Sends a DELETE request to the specified URL and returns a Promise that resolves to the response data. - * - * @param url - The URL to send the DELETE request to. - * @returns A Promise that resolves to the response data. - */ - delete(url: string): Promise { - return this.request(url, { - method: 'DELETE', - headers: { - 'Content-Type': 'application/json' - }, - credentials: 'include' - }) - } -} - -export const apiClient = new APIClient( - `${process.env.NEXT_PUBLIC_BACKEND_URL}/api` -) diff --git a/apps/platform/src/lib/workspace-storage.ts b/apps/platform/src/lib/workspace-storage.ts deleted file mode 100644 index 9d09dafb..00000000 --- a/apps/platform/src/lib/workspace-storage.ts +++ /dev/null @@ -1,30 +0,0 @@ -// import type { Workspace } from '@/types' -import type { Workspace } from '@keyshade/schema' - -export function setWorkspace(workspaceData: Workspace[]): void { - const defaultWorkspace = - workspaceData.find((workspace) => workspace.isDefault) || null - if (typeof localStorage !== 'undefined') { - localStorage.setItem('defaultWorkspace', JSON.stringify(defaultWorkspace)) - - if (getCurrentWorkspace() === null) { - localStorage.setItem('currentWorkspace', JSON.stringify(defaultWorkspace)) - } - } -} - -export function getCurrentWorkspace(): Workspace | null { - const currentWorkspace = - typeof localStorage !== 'undefined' - ? localStorage.getItem('currentWorkspace') - : `{}` - - if (currentWorkspace) { - return JSON.parse(currentWorkspace) as Workspace - } - return null -} - -export function setCurrentWorkspace(workspace: Workspace): void { - localStorage.setItem('currentWorkspace', JSON.stringify(workspace)) -}