-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ade59f6
commit 7aa4841
Showing
19 changed files
with
3,984 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cd ./client && yarn types && yarn check-types && git add src/types/generated/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cd ./client && yarn types && yarn check-types && git add src/types/generated/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Config } from '@orval/core'; | ||
|
||
export default { | ||
landgriffon: { | ||
output: { | ||
mode: 'tags', | ||
client: 'react-query', | ||
target: './src/types/generated/api.ts', | ||
mock: false, | ||
clean: true, | ||
prettier: true, | ||
override: { | ||
mutator: { | ||
path: './src/services/orval.ts', | ||
name: 'API', | ||
}, | ||
query: { | ||
useQuery: true, | ||
useMutation: true, | ||
signal: true, | ||
}, | ||
}, | ||
}, | ||
input: { | ||
target: '../api/swagger-spec.json', | ||
filters: { | ||
tags: ['User'], | ||
}, | ||
}, | ||
}, | ||
} satisfies Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Axios, { AxiosRequestConfig, AxiosError } from 'axios'; | ||
|
||
import { authorizedRequest, onResponseError } from './api'; | ||
|
||
export const apiService = Axios.create({ | ||
baseURL: `${process.env.NEXT_PUBLIC_API_URL}`, | ||
headers: { 'Content-Type': 'application/json' }, | ||
}); | ||
|
||
apiService.interceptors.request.use(authorizedRequest, onResponseError); | ||
|
||
// add a second `options` argument here if you want to pass extra options to each generated query | ||
export const API = <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig): Promise<T> => { | ||
const source = Axios.CancelToken.source(); | ||
const promise = apiService({ | ||
...config, | ||
...options, | ||
cancelToken: source.token, | ||
}).then(({ data }) => data); | ||
|
||
// @ts-expect-error cancel is not part of the promise | ||
promise.cancel = () => { | ||
source.cancel('Query was cancelled'); | ||
}; | ||
|
||
return promise; | ||
}; | ||
|
||
// In some case with react-query and swr you want to be able to override the return error type so you can also do it here like this | ||
export type ErrorType<Error> = AxiosError<Error>; | ||
|
||
export type BodyType<BodyData> = BodyData; | ||
|
||
export default API; |
Oops, something went wrong.