Skip to content

Commit 0349367

Browse files
committed
fix: add missing client.ts file for courtlistener-sdk to fix CI builds
- Add axios client configuration matching other SDKs pattern - Implement customInstance function required by Orval mutator - Include CourtListener API authentication token support - Fixes SDK generation failure in GitHub Actions workflows
1 parent 88233f6 commit 0349367

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import axios, { type AxiosRequestConfig } from 'axios';
2+
3+
export const customInstance = <T>(
4+
config: AxiosRequestConfig,
5+
options?: AxiosRequestConfig,
6+
): Promise<T> => {
7+
// Get auth token if available
8+
const authToken = process.env.COURTLISTENER_API_TOKEN;
9+
10+
const source = axios.CancelToken.source();
11+
const promise = axios({
12+
baseURL: 'https://www.courtlistener.com',
13+
timeout: 30000,
14+
headers: {
15+
'Content-Type': 'application/json',
16+
...(authToken && { 'Authorization': `Token ${authToken}` }),
17+
},
18+
...config,
19+
...options,
20+
cancelToken: source.token,
21+
}).then(({ data }) => data);
22+
23+
// @ts-ignore
24+
promise.cancel = () => {
25+
source.cancel('Query was cancelled by React Query');
26+
};
27+
28+
return promise;
29+
};
30+
31+
export default customInstance;

0 commit comments

Comments
 (0)