-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
11 changed files
with
70 additions
and
109 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
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 |
---|---|---|
@@ -1,28 +1,3 @@ | ||
import { HydrationBoundary, QueryClient, dehydrate } from '@tanstack/react-query'; | ||
import { FirstDomainExampleScreen } from '@sambad/web-domains/first-domain'; | ||
|
||
import { checkAPI } from '../../../packages/web-domains/src/common/apis/check.api'; | ||
import { FirstFeatureOfFirstDomainTestContainer } from '../../../packages/web-domains/src/first-domain/features/containers/FirstFeatureOfFirstDomainTestContainer'; | ||
|
||
import styles from './page.module.css'; | ||
|
||
export default async function FirstDomainExampleScreen() { | ||
const queryClient = new QueryClient(); | ||
|
||
await queryClient.prefetchQuery({ | ||
queryKey: ['health'], | ||
queryFn: async () => { | ||
return await checkAPI.Ping(''); | ||
}, | ||
}); | ||
|
||
return ( | ||
<main className={styles.main}> | ||
<HydrationBoundary state={dehydrate(queryClient)}> | ||
<div> | ||
<h1>도메인 화면을 전체 담당 하는 컴포넌트입니다.</h1> | ||
<FirstFeatureOfFirstDomainTestContainer /> | ||
</div> | ||
</HydrationBoundary>{' '} | ||
</main> | ||
); | ||
} | ||
export default FirstDomainExampleScreen; |
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 |
---|---|---|
@@ -1,41 +1,28 @@ | ||
import axios, { AxiosRequestConfig, AxiosInstance } from 'axios'; | ||
import axios from 'axios'; | ||
const baseURL = `/api`; | ||
|
||
export class Http { | ||
private instance: AxiosInstance; | ||
constructor(path: string) { | ||
path = path.startsWith('/') ? path.slice(1) : path; | ||
|
||
this.instance = axios.create({ | ||
baseURL: `${baseURL}/${path}`, | ||
}); | ||
} | ||
const axiosInstance = axios.create({ | ||
baseURL: baseURL, | ||
}); | ||
|
||
protected async GET<Response = unknown>(url: string, config?: AxiosRequestConfig) { | ||
const response = await this.instance.get<Response>(url, config); | ||
export class Http { | ||
static async GET<Response = unknown>(...args: Parameters<typeof axiosInstance.get>) { | ||
const response = await axiosInstance.get<Response>(...args); | ||
return response.data; | ||
} | ||
|
||
protected async POST<Request = unknown, Response = unknown>( | ||
url: string, | ||
payload?: Request, | ||
config?: AxiosRequestConfig, | ||
) { | ||
const response = await this.instance.post<Request, Response>(url, payload, config); | ||
static async POST<Request = unknown, Response = unknown>(...args: Parameters<typeof axiosInstance.post>) { | ||
const response = await axiosInstance.post<Request, Response>(...args); | ||
return response; | ||
} | ||
|
||
protected async PUT<Request = unknown, Response = unknown>( | ||
url: string, | ||
payload?: Request, | ||
config?: AxiosRequestConfig, | ||
) { | ||
const response = await this.instance.put<Request, Response>(url, payload, config); | ||
static async PUT<Request = unknown, Response = unknown>(...args: Parameters<typeof axiosInstance.put>) { | ||
const response = await axiosInstance.put<Request, Response>(...args); | ||
return response; | ||
} | ||
|
||
protected async DELETE<Response = unknown>(url: string, config?: AxiosRequestConfig) { | ||
const response = await this.instance.delete<Response>(url, config); | ||
static async DELETE<Response = unknown>(...args: Parameters<typeof axiosInstance.delete>) { | ||
const response = await axiosInstance.delete<Response>(...args); | ||
return response.data; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
packages/web-domains/src/common/apis/queries/useHealthCheckQuery.ts
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,28 @@ | ||
import { QueryClient, useQuery } from '@tanstack/react-query'; | ||
|
||
import { Http } from '../base.api'; | ||
|
||
const ping = () => Http.GET<any>('/actuator/health'); | ||
|
||
export const useHealthCheckQuery = () => { | ||
const { data } = useQuery({ | ||
queryKey: ['health'], | ||
queryFn: ping, | ||
}); | ||
|
||
return { data }; | ||
}; | ||
|
||
export const useHealthCheckPrefetchQuery = async () => { | ||
const queryClient = new QueryClient(); | ||
|
||
const prefetchedData = await queryClient.prefetchQuery({ | ||
queryKey: ['health'], | ||
queryFn: ping, | ||
}); | ||
|
||
return { | ||
queryClient, | ||
prefetchedData, | ||
}; | ||
}; |
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
15 changes: 2 additions & 13 deletions
15
...web-domains/src/first-domain/features/services/useFirstFeatureOfFirstDomainTestService.ts
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
14 changes: 3 additions & 11 deletions
14
packages/web-domains/src/first-domain/screens/FirstDomainExampleScreen.tsx
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.