diff --git a/apps/cs/package.json b/apps/cs/package.json index 0abb67d9d..1320f94dc 100644 --- a/apps/cs/package.json +++ b/apps/cs/package.json @@ -1,6 +1,6 @@ { "name": "cs", - "version": "0.1.0", + "version": "0.0.0", "private": true, "scripts": { "dev": "NODE_OPTIONS='--inspect' next dev", diff --git a/apps/cs/src/shared/api/client.ts b/apps/cs/src/shared/api/client.ts index 2a7d58988..e63a4813e 100644 --- a/apps/cs/src/shared/api/client.ts +++ b/apps/cs/src/shared/api/client.ts @@ -1,62 +1,7 @@ -import axios from "axios"; -import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios"; +import { Client } from "@common/network"; import { SERVER_API_URL, SITE_ID } from "../config"; -class Client { - private static instance: Client; - private axiosInstance: AxiosInstance; - - private constructor() { - this.axiosInstance = axios.create({ - baseURL: SERVER_API_URL, - headers: { - "Content-Type": "application/json", - "X-Site-Id": SITE_ID, - }, - withCredentials: true, - }); - } - - public static getInstance(): Client { - if (!Client.instance) { - Client.instance = new Client(); - } - return Client.instance; - } - - public async get>( - url: string, - config?: AxiosRequestConfig, - ): Promise { - const response = await this.axiosInstance.get(url, config); - return response; - } - - public async post, D = unknown>( - url: string, - data?: D, - config?: AxiosRequestConfig, - ): Promise { - const response = await this.axiosInstance.post(url, data, config); - return response; - } - - public async put, D = unknown>( - url: string, - data?: D, - config?: AxiosRequestConfig, - ): Promise { - const response = await this.axiosInstance.put(url, data, config); - return response; - } - - public async delete>( - url: string, - config?: AxiosRequestConfig, - ): Promise { - const response = await this.axiosInstance.delete(url, config); - return response; - } -} - -export const client = Client.getInstance(); +export const client = Client.getInstance({ + baseURL: SERVER_API_URL as string, + siteId: SITE_ID as string, +}); diff --git a/apps/cs/tsconfig.json b/apps/cs/tsconfig.json index 753fd0927..9e77e1146 100644 --- a/apps/cs/tsconfig.json +++ b/apps/cs/tsconfig.json @@ -26,7 +26,9 @@ "paths": { "@/*": ["./*"], "@common/components/*": ["../../../packages/common/components/src/*"], - "@common/components": ["../../../packages/common/components/src"] + "@common/components": ["../../../packages/common/components/src"], + "@common/network/*": ["../../../packages/common/network/*"], + "@common/network": ["../../../packages/common/network/"] } }, "include": [