Skip to content
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

⚙️ MSW setting #11

Merged
merged 13 commits into from
Oct 26, 2024
13 changes: 11 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import type { Metadata } from 'next';

import { QueryProvider } from '@/app/provider';
import { MSWProvider } from '@/app/mocks';
import { QueryProvider } from '@/app/query';
import './globals.css';

if (process.env.NEXT_RUNTIME === 'nodejs') {
import('@/app/mocks').then(({ server }) => {
server.listen();
});
}

export const metadata: Metadata = {
title: 'Pennyway',
description: '💰 Pennyway : 지출 내역을 관리하고 공유하는 플랫폼',
Expand All @@ -16,7 +23,9 @@ export default function RootLayout({
return (
<html lang="ko">
<body>
<QueryProvider>{children}</QueryProvider>
<MSWProvider>
<QueryProvider>{children}</QueryProvider>
</MSWProvider>
</body>
</html>
);
Expand Down
19 changes: 18 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
import axios from 'axios';

import IconArrowFront from '/public/assets/icon/arrow-front.svg';

import { PageContainer } from '@/widgets/pageContainer/ui/PageContainer';
export default function Home() {

type User = {
firstName: string;
lastName: string;
};

async function getUser() {
const result = await axios.get('https://api.example.com/user');
const user = result.data as User;
return user;
}

export default async function Home() {
const user = await getUser();

return (
<PageContainer
headerProps={{
Expand All @@ -11,6 +27,7 @@ export default function Home() {
}}
>
<div className="mt-[44px] flex flex-col justify-center gap-12 bg-[#666666]">
<p id="server-side-greeting">Hello, {user.firstName}!</p>
<div className="w-72">
<p className="bg-white text-black">White</p>
<p className="bg-gray01 text-black">Gray 01</p>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"axios": "^1.7.7",
"ky": "^1.7.2",
"next": "14.2.14",
"react": "^18",
Expand Down
30 changes: 30 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading