diff --git a/.changeset/flat-cars-yell.md b/.changeset/flat-cars-yell.md new file mode 100644 index 00000000..9f550d5d --- /dev/null +++ b/.changeset/flat-cars-yell.md @@ -0,0 +1,6 @@ +--- +"docs": major +"@nf-team/fetch": major +--- + +feat(@nf-team/fetch): v1 fetch api 공통 패키지 구현 diff --git a/.yarn/cache/@esbuild-darwin-arm64-npm-0.21.5-62349c1520-10.zip b/.yarn/cache/@esbuild-darwin-arm64-npm-0.21.5-62349c1520-10.zip new file mode 100644 index 00000000..cf67cd85 Binary files /dev/null and b/.yarn/cache/@esbuild-darwin-arm64-npm-0.21.5-62349c1520-10.zip differ diff --git a/.yarn/cache/@esbuild-linux-arm64-npm-0.21.5-c6a54cd648-10.zip b/.yarn/cache/@esbuild-linux-arm64-npm-0.21.5-c6a54cd648-10.zip new file mode 100644 index 00000000..4754b51a Binary files /dev/null and b/.yarn/cache/@esbuild-linux-arm64-npm-0.21.5-c6a54cd648-10.zip differ diff --git a/.yarn/cache/@rollup-rollup-darwin-arm64-npm-4.4.1-0124a9273e-10.zip b/.yarn/cache/@rollup-rollup-darwin-arm64-npm-4.4.1-0124a9273e-10.zip new file mode 100644 index 00000000..8b855a62 Binary files /dev/null and b/.yarn/cache/@rollup-rollup-darwin-arm64-npm-4.4.1-0124a9273e-10.zip differ diff --git a/.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.4.1-8ac85f164e-10.zip b/.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.4.1-8ac85f164e-10.zip deleted file mode 100644 index 316722ce..00000000 Binary files a/.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.4.1-8ac85f164e-10.zip and /dev/null differ diff --git a/.yarn/cache/@swc-core-linux-x64-gnu-npm-1.3.96-01459a118a-10.zip b/.yarn/cache/@swc-core-darwin-arm64-npm-1.3.96-6c495b7164-10.zip similarity index 57% rename from .yarn/cache/@swc-core-linux-x64-gnu-npm-1.3.96-01459a118a-10.zip rename to .yarn/cache/@swc-core-darwin-arm64-npm-1.3.96-6c495b7164-10.zip index 744d764b..5c6ff253 100644 Binary files a/.yarn/cache/@swc-core-linux-x64-gnu-npm-1.3.96-01459a118a-10.zip and b/.yarn/cache/@swc-core-darwin-arm64-npm-1.3.96-6c495b7164-10.zip differ diff --git a/.yarn/cache/turbo-darwin-arm64-npm-2.0.5-b6d4e32b48-10.zip b/.yarn/cache/turbo-darwin-arm64-npm-2.0.5-b6d4e32b48-10.zip new file mode 100644 index 00000000..fe721a54 Binary files /dev/null and b/.yarn/cache/turbo-darwin-arm64-npm-2.0.5-b6d4e32b48-10.zip differ diff --git a/.yarn/cache/turbo-linux-arm64-npm-2.0.5-8ec7f6fd44-10.zip b/.yarn/cache/turbo-linux-arm64-npm-2.0.5-8ec7f6fd44-10.zip new file mode 100644 index 00000000..8140166b Binary files /dev/null and b/.yarn/cache/turbo-linux-arm64-npm-2.0.5-8ec7f6fd44-10.zip differ diff --git a/.yarnrc.yml b/.yarnrc.yml index 1ef59dad..87ed8963 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -4,4 +4,12 @@ enableGlobalCache: false nodeLinker: node-modules +supportedArchitectures: + os: + - darwin + - linux + cpu: + - x64 + - arm64 + yarnPath: .yarn/releases/yarn-4.4.0.cjs diff --git a/apps/docs/docs/core/modules.md b/apps/docs/docs/core/modules.md index 69728933..727023cc 100644 --- a/apps/docs/docs/core/modules.md +++ b/apps/docs/docs/core/modules.md @@ -1,6 +1,6 @@ --- id: "modules" -title: "@nf-team/core - v2.0.2" +title: "@nf-team/core - v2.1.0" sidebar_label: "Exports" sidebar_position: 0.5 custom_edit_url: null @@ -30,7 +30,7 @@ custom_edit_url: null #### Defined in -[utils.ts:44](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/core/src/utils.ts#L44) +[utils.ts:44](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/core/src/utils.ts#L44) ___ @@ -50,7 +50,7 @@ ___ #### Defined in -[utils.ts:26](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/core/src/utils.ts#L26) +[utils.ts:26](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/core/src/utils.ts#L26) ___ @@ -71,7 +71,7 @@ ___ #### Defined in -[utils.ts:34](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/core/src/utils.ts#L34) +[utils.ts:34](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/core/src/utils.ts#L34) ___ @@ -91,7 +91,7 @@ ___ #### Defined in -[utils.ts:64](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/core/src/utils.ts#L64) +[utils.ts:64](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/core/src/utils.ts#L64) ___ @@ -117,7 +117,7 @@ ___ #### Defined in -[utils.ts:52](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/core/src/utils.ts#L52) +[utils.ts:52](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/core/src/utils.ts#L52) ___ @@ -153,7 +153,7 @@ console.log(result); // 'newValue'; #### Defined in -[utils.ts:14](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/core/src/utils.ts#L14) +[utils.ts:14](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/core/src/utils.ts#L14) ___ @@ -173,4 +173,4 @@ ___ #### Defined in -[utils.ts:36](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/core/src/utils.ts#L36) +[utils.ts:36](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/core/src/utils.ts#L36) diff --git a/apps/docs/docs/fetch/_category_.yml b/apps/docs/docs/fetch/_category_.yml new file mode 100644 index 00000000..346c040b --- /dev/null +++ b/apps/docs/docs/fetch/_category_.yml @@ -0,0 +1,2 @@ +label: "@nf-team/fetch" +position: 4 \ No newline at end of file diff --git a/apps/docs/docs/fetch/index.md b/apps/docs/docs/fetch/index.md new file mode 100644 index 00000000..984c2b32 --- /dev/null +++ b/apps/docs/docs/fetch/index.md @@ -0,0 +1,25 @@ +--- +id: "index" +title: "@nf-team/fetch" +sidebar_label: "Readme" +sidebar_position: 0 +custom_edit_url: null +--- + +# @nf-team/fetch + + + + + + + + + +[Check out our @nf-team/fetch libraries docs.](https://mbti-nf-team.github.io/frontend-libraries/docs/fetch) + +## 🐛 Bug reporting +[Issues](https://github.com/mbti-nf-team/frontend-libraries/issues) + +## 🔒 LICENSE +This libraries is [MIT licensed](https://github.com/mbti-nf-team/frontend-libraries/blob/main/packages/fetch/LICENSE). diff --git a/apps/docs/docs/fetch/interfaces/FetchApiRequest.md b/apps/docs/docs/fetch/interfaces/FetchApiRequest.md new file mode 100644 index 00000000..a7cae40f --- /dev/null +++ b/apps/docs/docs/fetch/interfaces/FetchApiRequest.md @@ -0,0 +1,63 @@ +--- +id: "FetchApiRequest" +title: "Interface: FetchApiRequest" +sidebar_label: "FetchApiRequest" +sidebar_position: 0 +custom_edit_url: null +--- + +## Type parameters + +| Name | Type | +| :------ | :------ | +| `K` | `unknown` | + +## Properties + +### body + +• `Optional` **body**: `unknown` + +#### Defined in + +[fetch.ts:19](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/fetch/src/fetch.ts#L19) + +___ + +### config + +• `Optional` **config**: `Omit`\<`RequestInit`, ``"method"`` \| ``"body"``\> + +#### Defined in + +[fetch.ts:20](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/fetch/src/fetch.ts#L20) + +___ + +### method + +• `Optional` **method**: [`Method`](../modules.md#method) + +#### Defined in + +[fetch.ts:18](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/fetch/src/fetch.ts#L18) + +___ + +### params + +• `Optional` **params**: `K` + +#### Defined in + +[fetch.ts:17](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/fetch/src/fetch.ts#L17) + +___ + +### url + +• **url**: `string` + +#### Defined in + +[fetch.ts:16](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/fetch/src/fetch.ts#L16) diff --git a/apps/docs/docs/fetch/interfaces/_category_.yml b/apps/docs/docs/fetch/interfaces/_category_.yml new file mode 100644 index 00000000..43bec88c --- /dev/null +++ b/apps/docs/docs/fetch/interfaces/_category_.yml @@ -0,0 +1,2 @@ +label: "Interfaces" +position: 4 \ No newline at end of file diff --git a/apps/docs/docs/fetch/modules.md b/apps/docs/docs/fetch/modules.md new file mode 100644 index 00000000..91356aef --- /dev/null +++ b/apps/docs/docs/fetch/modules.md @@ -0,0 +1,74 @@ +--- +id: "modules" +title: "@nf-team/fetch - v0.0.0" +sidebar_label: "Exports" +sidebar_position: 0.5 +custom_edit_url: null +--- + +## Interfaces + +- [FetchApiRequest](interfaces/FetchApiRequest.md) + +## Type Aliases + +### Method + +Ƭ **Method**: ``"get"`` \| ``"GET"`` \| ``"delete"`` \| ``"DELETE"`` \| ``"head"`` \| ``"HEAD"`` \| ``"options"`` \| ``"OPTIONS"`` \| ``"post"`` \| ``"POST"`` \| ``"put"`` \| ``"PUT"`` \| ``"patch"`` \| ``"PATCH"`` \| ``"purge"`` \| ``"PURGE"`` \| ``"link"`` \| ``"LINK"`` \| ``"unlink"`` \| ``"UNLINK"`` + +#### Defined in + +[fetch.ts:3](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/fetch/src/fetch.ts#L3) + +## Functions + +### fetchApi + +▸ **fetchApi**\<`T`, `K`\>(`«destructured»`): `Promise`\<`T`\> + +#### Type parameters + +| Name | Type | +| :------ | :------ | +| `T` | `T` | +| `K` | `unknown` | + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`FetchApiRequest`](interfaces/FetchApiRequest.md)\<`K`\> | + +#### Returns + +`Promise`\<`T`\> + +#### Defined in + +[fetch.ts:28](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/fetch/src/fetch.ts#L28) + +___ + +### paramsSerializer + +▸ **paramsSerializer**\<`T`\>(`params`): `string` + +#### Type parameters + +| Name | +| :------ | +| `T` | + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `params` | `T` | + +#### Returns + +`string` + +#### Defined in + +[fetch.ts:23](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/fetch/src/fetch.ts#L23) diff --git a/apps/docs/docs/index.md b/apps/docs/docs/index.md index 6d7d2314..a71cfe59 100644 --- a/apps/docs/docs/index.md +++ b/apps/docs/docs/index.md @@ -10,3 +10,4 @@ custom_edit_url: null - [@nf-team/react](react/index.md) - [@nf-team/eslint-config](eslint-config/index.md) - [@nf-team/stylelint-config](stylelint-config/index.md) +- [@nf-team/fetch](fetch/index.md) diff --git a/apps/docs/docs/react/modules.md b/apps/docs/docs/react/modules.md index 7760de65..3b5b9a07 100644 --- a/apps/docs/docs/react/modules.md +++ b/apps/docs/docs/react/modules.md @@ -1,6 +1,6 @@ --- id: "modules" -title: "@nf-team/react - v2.5.0" +title: "@nf-team/react - v2.7.1" sidebar_label: "Exports" sidebar_position: 0.5 custom_edit_url: null diff --git a/apps/docs/docs/react/modules/components.md b/apps/docs/docs/react/modules/components.md index 99988646..bb833a67 100644 --- a/apps/docs/docs/react/modules/components.md +++ b/apps/docs/docs/react/modules/components.md @@ -44,7 +44,7 @@ function ClintOnlyComponent() { #### Defined in -[packages/react/src/components/ClientOnly.tsx:22](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/components/ClientOnly.tsx#L22) +[packages/react/src/components/ClientOnly.tsx:22](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/components/ClientOnly.tsx#L22) ___ @@ -64,7 +64,7 @@ ___ #### Defined in -[packages/react/src/components/DelayRenderComponent.tsx:12](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/components/DelayRenderComponent.tsx#L12) +[packages/react/src/components/DelayRenderComponent.tsx:12](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/components/DelayRenderComponent.tsx#L12) ___ @@ -108,4 +108,4 @@ function SampleComponent() { #### Defined in -[packages/react/src/components/GlobalPortal.tsx:34](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/components/GlobalPortal.tsx#L34) +[packages/react/src/components/GlobalPortal.tsx:34](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/components/GlobalPortal.tsx#L34) diff --git a/apps/docs/docs/react/modules/hooks.md b/apps/docs/docs/react/modules/hooks.md index e6f7d742..e14a7093 100644 --- a/apps/docs/docs/react/modules/hooks.md +++ b/apps/docs/docs/react/modules/hooks.md @@ -32,7 +32,7 @@ custom_edit_url: null #### Defined in -[packages/react/src/hooks/useActionKeyEvent.ts:6](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useActionKeyEvent.ts#L6) +[packages/react/src/hooks/useActionKeyEvent.ts:6](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useActionKeyEvent.ts#L6) ___ @@ -62,7 +62,7 @@ const [isOpen, openModal, closeModal, toggleModal] = useBoolean(); #### Defined in -[packages/react/src/hooks/useBoolean.ts:13](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useBoolean.ts#L13) +[packages/react/src/hooks/useBoolean.ts:13](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useBoolean.ts#L13) ___ @@ -89,7 +89,7 @@ ___ #### Defined in -[packages/react/src/hooks/useDebounce.ts:3](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useDebounce.ts#L3) +[packages/react/src/hooks/useDebounce.ts:3](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useDebounce.ts#L3) ___ @@ -109,7 +109,7 @@ ___ #### Defined in -[packages/react/src/hooks/useEffectOnce.ts:3](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useEffectOnce.ts#L3) +[packages/react/src/hooks/useEffectOnce.ts:3](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useEffectOnce.ts#L3) ___ @@ -123,7 +123,7 @@ ___ #### Defined in -[packages/react/src/hooks/useGeolocation.ts:15](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useGeolocation.ts#L15) +[packages/react/src/hooks/useGeolocation.ts:15](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useGeolocation.ts#L15) ___ @@ -137,7 +137,7 @@ ___ #### Defined in -[packages/react/src/hooks/useIsFirstRender.ts:3](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useIsFirstRender.ts#L3) +[packages/react/src/hooks/useIsFirstRender.ts:3](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useIsFirstRender.ts#L3) ___ @@ -169,7 +169,7 @@ useEffect(() => { #### Defined in -[packages/react/src/hooks/useIsMounted.ts:18](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useIsMounted.ts#L18) +[packages/react/src/hooks/useIsMounted.ts:18](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useIsMounted.ts#L18) ___ @@ -196,11 +196,11 @@ Accepts a function that contains imperative, possibly effectful code. **`See`** -https://react.dev/reference/react/useEffect +[https://react.dev/reference/react/useEffect](https://react.dev/reference/react/useEffect) #### Defined in -node_modules/@types/react/index.d.ts:1095 +node_modules/@types/react/index.d.ts:2031 ___ @@ -221,7 +221,7 @@ ___ #### Defined in -[packages/react/src/hooks/useLessThenScrollY.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useLessThenScrollY.ts#L5) +[packages/react/src/hooks/useLessThenScrollY.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useLessThenScrollY.ts#L5) ___ @@ -251,7 +251,7 @@ function SampleComponent() { #### Defined in -[packages/react/src/hooks/useResizeViewportHeight.ts:17](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useResizeViewportHeight.ts#L17) +[packages/react/src/hooks/useResizeViewportHeight.ts:17](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useResizeViewportHeight.ts#L17) ___ @@ -291,7 +291,7 @@ ___ #### Defined in -[packages/react/src/hooks/useThrottleCallback.ts:3](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useThrottleCallback.ts#L3) +[packages/react/src/hooks/useThrottleCallback.ts:3](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useThrottleCallback.ts#L3) ___ @@ -312,7 +312,7 @@ ___ #### Defined in -[packages/react/src/hooks/useTimeout.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useTimeout.ts#L5) +[packages/react/src/hooks/useTimeout.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useTimeout.ts#L5) ___ @@ -332,7 +332,7 @@ ___ #### Defined in -[packages/react/src/hooks/useUnmount.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useUnmount.ts#L5) +[packages/react/src/hooks/useUnmount.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useUnmount.ts#L5) ___ @@ -353,4 +353,4 @@ ___ #### Defined in -[packages/react/src/hooks/useUpdateEffect.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/react/src/hooks/useUpdateEffect.ts#L5) +[packages/react/src/hooks/useUpdateEffect.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/react/src/hooks/useUpdateEffect.ts#L5) diff --git a/apps/docs/docs/storage/modules.md b/apps/docs/docs/storage/modules.md index aa5fbde2..d4dd4301 100644 --- a/apps/docs/docs/storage/modules.md +++ b/apps/docs/docs/storage/modules.md @@ -1,6 +1,6 @@ --- id: "modules" -title: "@nf-team/storage - v1.0.0" +title: "@nf-team/storage - v1.1.0" sidebar_label: "Exports" sidebar_position: 0.5 custom_edit_url: null @@ -30,7 +30,7 @@ custom_edit_url: null #### Defined in -[localStorage.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/storage/src/localStorage.ts#L5) +[localStorage.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/storage/src/localStorage.ts#L5) ___ @@ -56,7 +56,7 @@ ___ #### Defined in -[sessionStorage.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/storage/src/sessionStorage.ts#L5) +[sessionStorage.ts:5](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/storage/src/sessionStorage.ts#L5) ___ @@ -76,7 +76,7 @@ ___ #### Defined in -[localStorage.ts:20](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/storage/src/localStorage.ts#L20) +[localStorage.ts:20](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/storage/src/localStorage.ts#L20) ___ @@ -96,7 +96,7 @@ ___ #### Defined in -[sessionStorage.ts:20](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/storage/src/sessionStorage.ts#L20) +[sessionStorage.ts:20](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/storage/src/sessionStorage.ts#L20) ___ @@ -117,7 +117,7 @@ ___ #### Defined in -[localStorage.ts:1](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/storage/src/localStorage.ts#L1) +[localStorage.ts:1](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/storage/src/localStorage.ts#L1) ___ @@ -138,4 +138,4 @@ ___ #### Defined in -[sessionStorage.ts:1](https://github.com/mbti-nf-team/frontend-libraries/blob/5614e38/packages/storage/src/sessionStorage.ts#L1) +[sessionStorage.ts:1](https://github.com/mbti-nf-team/frontend-libraries/blob/35d6e12/packages/storage/src/sessionStorage.ts#L1) diff --git a/apps/docs/docusaurus.config.ts b/apps/docs/docusaurus.config.ts index 860066ae..2e11b6e6 100644 --- a/apps/docs/docusaurus.config.ts +++ b/apps/docs/docusaurus.config.ts @@ -63,6 +63,20 @@ const config: Config = { }, }, ], + [ + 'docusaurus-plugin-typedoc', + { + id: 'api-4', + entryPoints: ['../../packages/fetch'], + entryPointStrategy: 'packages', + out: 'fetch', + sidebar: { + fullNames: true, + position: 4, + categoryLabel: '@nf-team/fetch', + }, + }, + ], ], markdown: { format: 'mdx', @@ -132,6 +146,12 @@ const config: Config = { label: '@nf-team/stylelint-config', position: 'left', }, + { + to: 'docs/fetch', + activeBasePath: 'docs/fetch', + label: '@nf-team/fetch', + position: 'left', + }, { href: 'https://github.com/mbti-nf-team/frontend-libraries', label: 'GitHub', @@ -165,6 +185,10 @@ const config: Config = { label: '@nf-team/stylelint-config', to: '/docs/stylelint-config', }, + { + label: '@nf-team/fetch', + to: '/docs/fetch', + }, ], }, { diff --git a/packages/fetch/.eslintrc.js b/packages/fetch/.eslintrc.js new file mode 100644 index 00000000..0391fe97 --- /dev/null +++ b/packages/fetch/.eslintrc.js @@ -0,0 +1,38 @@ +module.exports = { + root: true, + env: { + es6: true, + browser: true, + jest: true, + }, + ignorePatterns: [ + 'node_modules/', + 'public/', + 'dist/', + 'coverage/', + ], + plugins: ['eslint-plugin-tsdoc'], + extends: ['@nf-team/eslint-config'], + overrides: [ + { + files: ['*.ts', '*.tsx'], + parser: '@typescript-eslint/parser', + parserOptions: { + project: ['./tsconfig.json'], + }, + }, + { + files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'], + rules: { + 'react-hooks/rules-of-hooks': 'off', + '@typescript-eslint/no-explicit-any': 'off', + }, + }, + ], + rules: { + 'import/export': 'off', + 'import/prefer-default-export': 'off', + 'import/no-extraneous-dependencies': 'off', + 'tsdoc/syntax': 'warn', + }, +}; diff --git a/packages/fetch/LICENSE b/packages/fetch/LICENSE new file mode 100644 index 00000000..8417f29d --- /dev/null +++ b/packages/fetch/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 NFTeam + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/fetch/README.md b/packages/fetch/README.md new file mode 100644 index 00000000..8e44c872 --- /dev/null +++ b/packages/fetch/README.md @@ -0,0 +1,17 @@ +# @nf-team/fetch + + + + + + + + + +[Check out our @nf-team/fetch libraries docs.](https://mbti-nf-team.github.io/frontend-libraries/docs/fetch) + +## 🐛 Bug reporting +[Issues](https://github.com/mbti-nf-team/frontend-libraries/issues) + +## 🔒 LICENSE +This libraries is [MIT licensed](https://github.com/mbti-nf-team/frontend-libraries/blob/main/packages/fetch/LICENSE). diff --git a/packages/fetch/jest.config.js b/packages/fetch/jest.config.js new file mode 100644 index 00000000..e255d50c --- /dev/null +++ b/packages/fetch/jest.config.js @@ -0,0 +1,11 @@ +module.exports = { + transform: { + '^.+\\.(t|j)sx?$': [ + '@swc/jest', + ], + }, + setupFilesAfterEnv: ['/jest.setup.js'], + testPathIgnorePatterns: ['node_modules'], + moduleDirectories: ['node_modules', '/'], + testEnvironment: 'jest-environment-jsdom', +}; diff --git a/packages/fetch/jest.setup.js b/packages/fetch/jest.setup.js new file mode 100644 index 00000000..c7a8f62b --- /dev/null +++ b/packages/fetch/jest.setup.js @@ -0,0 +1,2 @@ +import 'jest-plugin-context/setup'; +import 'given2/setup'; diff --git a/packages/fetch/package.json b/packages/fetch/package.json new file mode 100644 index 00000000..a558b7b3 --- /dev/null +++ b/packages/fetch/package.json @@ -0,0 +1,53 @@ +{ + "name": "@nf-team/fetch", + "version": "0.0.0", + "description": "nf-team fetch", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "license": "MIT", + "author": { + "email": "dbd02169@naver.com", + "name": "SEUNGMIN SA (Harang)", + "url": "https://github.com/saseungmin" + }, + "repository": { + "type": "git", + "url": "https://github.com/mbti-nf-team/frontend-libraries.git" + }, + "homepage": "https://mbti-nf-team.github.io/frontend-libraries/docs/fetch", + "scripts": { + "build": "tsup src/index.ts --format cjs --dts", + "dev": "yarn run build -- --watch", + "test:unit": "jest", + "test:watch": "jest --watch", + "test:watchAll": "jest --watchAll", + "test:coverage": "yarn test:unit --coverage", + "lint": "eslint \"**/*.ts*\"" + }, + "devDependencies": { + "@nf-team/eslint-config": "3.3.0", + "@nf-team/tsconfig": "1.0.0", + "@swc/core": "^1.3.96", + "@swc/jest": "^0.2.29", + "@types/jest": "^29.5.2", + "@types/jest-plugin-context": "^2.9.5", + "eslint": "^8.56.0", + "eslint-plugin-tsdoc": "^0.2.17", + "given2": "^2.1.7", + "jest": "^29.5.0", + "jest-environment-jsdom": "^29.5.0", + "jest-plugin-context": "^2.9.0", + "tsup": "^8.1.0", + "typescript": "5.1.3" + }, + "peerDependencies": { + "qs": "^6.0.0" + }, + "publishConfig": { + "access": "public" + }, + "bugs": { + "email": "dbd02169@naver.com", + "url": "https://github.com/mbti-nf-team/frontend-libraries/issues" + } +} diff --git a/packages/fetch/src/fetch.ts b/packages/fetch/src/fetch.ts new file mode 100644 index 00000000..3a5d5cf1 --- /dev/null +++ b/packages/fetch/src/fetch.ts @@ -0,0 +1,50 @@ +import QueryString from 'qs'; + +export type Method = + | 'get' | 'GET' + | 'delete' | 'DELETE' + | 'head' | 'HEAD' + | 'options' | 'OPTIONS' + | 'post' | 'POST' + | 'put' | 'PUT' + | 'patch' | 'PATCH' + | 'purge' | 'PURGE' + | 'link' | 'LINK' + | 'unlink' | 'UNLINK'; + +export interface FetchApiRequest { + url: string; + params?: K; + method?: Method; + body?: unknown; + config?: Omit; +} + +export const paramsSerializer = (params: T): string => QueryString.stringify(params, { + arrayFormat: 'comma', + indices: false, +}); + +async function fetchApi({ + url, + params, + body, + config = {}, + method = 'GET', +}: FetchApiRequest): Promise { + const response = await fetch(`${url}${params ? `?${paramsSerializer(params)}` : ''}`, { + ...config, + body: body ? JSON.stringify(body) : undefined, + method, + headers: body ? { + 'Content-Type': 'application/json', + ...config.headers, + } : config.headers, + }); + + const data = await response.json() as T; + + return data; +} + +export default fetchApi; diff --git a/packages/fetch/src/index.ts b/packages/fetch/src/index.ts new file mode 100644 index 00000000..ae99a8e8 --- /dev/null +++ b/packages/fetch/src/index.ts @@ -0,0 +1,3 @@ +export { + default as fetchApi, type FetchApiRequest, type Method, paramsSerializer, +} from './fetch'; diff --git a/packages/fetch/tsconfig.json b/packages/fetch/tsconfig.json new file mode 100644 index 00000000..6742a3b6 --- /dev/null +++ b/packages/fetch/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "@nf-team/tsconfig/base.json", + "include": ["."], + "exclude": ["dist", "build", "node_modules"] +} diff --git a/packages/fetch/typedoc.json b/packages/fetch/typedoc.json new file mode 100644 index 00000000..d07bd2a3 --- /dev/null +++ b/packages/fetch/typedoc.json @@ -0,0 +1,5 @@ +{ + "extends": ["../../typedoc.base.json"], + "entryPoints": ["src/index.ts"], + "out": "./docs" +} diff --git a/yarn.lock b/yarn.lock index 5623b728..e3a9eeae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3305,6 +3305,29 @@ __metadata: languageName: unknown linkType: soft +"@nf-team/fetch@workspace:packages/fetch": + version: 0.0.0-use.local + resolution: "@nf-team/fetch@workspace:packages/fetch" + dependencies: + "@nf-team/eslint-config": "npm:3.3.0" + "@nf-team/tsconfig": "npm:1.0.0" + "@swc/core": "npm:^1.3.96" + "@swc/jest": "npm:^0.2.29" + "@types/jest": "npm:^29.5.2" + "@types/jest-plugin-context": "npm:^2.9.5" + eslint: "npm:^8.56.0" + eslint-plugin-tsdoc: "npm:^0.2.17" + given2: "npm:^2.1.7" + jest: "npm:^29.5.0" + jest-environment-jsdom: "npm:^29.5.0" + jest-plugin-context: "npm:^2.9.0" + tsup: "npm:^8.1.0" + typescript: "npm:5.1.3" + peerDependencies: + qs: ^6.0.0 + languageName: unknown + linkType: soft + "@nf-team/react@workspace:packages/react": version: 0.0.0-use.local resolution: "@nf-team/react@workspace:packages/react"