Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
29 lines
1001 B
TypeScript
29 lines
1001 B
TypeScript
import type { AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
|
|
import type { ApiResponse } from '@/services/apiResponse'
|
|
import axiosInstance from '@/config/axios'
|
|
|
|
/**
|
|
* Adapter used by generated Orval endpoints.
|
|
*
|
|
* OpenAPI paths include `/api/v1`, while the shared Axios instance already
|
|
* uses that prefix in its base URL. Keeping the normalization here lets both
|
|
* generated endpoints and the existing hand-written services share the same
|
|
* authentication, refresh-token, credentials, and observability interceptors.
|
|
*/
|
|
export const orvalClient = <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig): Promise<AxiosResponse<ApiResponse<T>>> => {
|
|
const url = config.url?.replace(/^\/api\/v1\/?/, '')
|
|
|
|
return axiosInstance.request<ApiResponse<T>>({
|
|
...config,
|
|
...options,
|
|
url,
|
|
headers: {
|
|
...(config.headers as Record<string, string> | undefined),
|
|
...(options?.headers as Record<string, string> | undefined),
|
|
},
|
|
})
|
|
}
|
|
|
|
export default orvalClient
|