-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#465] [모임] BookInfoCard 컴포넌트 추상화 #466
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,45 @@ | ||
import React from 'react'; | ||
|
||
import { rest } from 'msw'; | ||
import { initialize, mswLoader } from 'msw-storybook-addon'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import type { Preview } from '@storybook/react'; | ||
import '@/styles/global.css'; | ||
|
||
import Layout from '../src/v1/layout/Layout'; | ||
import ToastProvider from '../src/v1/base/Toast/ToastProvider'; | ||
|
||
import '@/styles/global.css'; | ||
|
||
const nextApi = (path: string) => | ||
new URL(path, process.env.NEXT_HOST).toString(); | ||
|
||
const serviceApi = (path: string) => | ||
new URL(path, process.env.NEXT_PUBLIC_API_URL).toString(); | ||
|
||
initialize({}, [ | ||
rest.get(nextApi('/service-api/*'), async (req, res, ctx) => { | ||
const { pathname } = req.url; | ||
const match = /\/service-api(?<path>.*)/g.exec(pathname); | ||
|
||
if (!match || !match.groups || !match.groups.path) { | ||
return res(ctx.status(404, 'Invalid Request URL')); | ||
} | ||
Comment on lines
+23
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ask; 이 조건부에서 만약 match.groups가 true이면 404에러를 띄워주는것으로 이해했는데 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const match = /\/service-api(?<path>.*)/g.exec(pathname); 앗.. 정규표현식에서 스토리북 전역에 queryclinet provider를 추가했기 때문에 nextApi 서버의 url로 들어오는 모든 요청을 처리할 수 있도록 구현했어요. 다독다독에서는 api 요청 url에 모두 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아하 match에 group이 독서 모임의 group이 아니였군요..! |
||
|
||
const { path } = match.groups; | ||
const originResponse = await ctx.fetch(serviceApi(`/api${path}`)); | ||
const originResponseData = await originResponse.json(); | ||
|
||
return res(ctx.json({ ...originResponseData })); | ||
}), | ||
]); | ||
|
||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
retry: false, | ||
}, | ||
}, | ||
}); | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
actions: { argTypesRegex: '^on[A-Z].*' }, | ||
|
@@ -20,13 +54,16 @@ const preview: Preview = { | |
}, | ||
layout: 'fullscreen', | ||
}, | ||
loaders: [mswLoader], | ||
decorators: [ | ||
Story => ( | ||
<ToastProvider> | ||
<Layout> | ||
<Story /> | ||
</Layout> | ||
</ToastProvider> | ||
<QueryClientProvider client={queryClient}> | ||
<ToastProvider> | ||
<Layout> | ||
<Story /> | ||
</Layout> | ||
</ToastProvider> | ||
</QueryClientProvider> | ||
), | ||
], | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,8 @@ | |
"less": "^4.1.3", | ||
"less-loader": "^11.1.3", | ||
"lint-staged": "^13.1.1", | ||
"msw": "1.3.2", | ||
"msw-storybook-addon": "^1.10.0", | ||
"postcss": "^8.4.25", | ||
"prettier": "^2.8.4", | ||
"prettier-plugin-tailwindcss": "^0.3.0", | ||
|
@@ -70,5 +72,8 @@ | |
] | ||
}, | ||
"readme": "ERROR: No README data found!", | ||
"_id": "[email protected]" | ||
"_id": "[email protected]", | ||
"msw": { | ||
"workerDirectory": "public" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍