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

chore, style : 프로젝트 아키텍처 세팅 #14

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
Empty file modified .husky/pre-push
100644 → 100755
Empty file.
Binary file removed app/favicon.ico
Binary file not shown.
13 changes: 6 additions & 7 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import type { Metadata } from "next";
import "./globals.css";
"use client";

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
import "./globals.css";
import AppProvider from "@/provider";

export default function RootLayout({
children,
Expand All @@ -13,7 +10,9 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body>{children}</body>
<body>
<AppProvider>{children}</AppProvider>
</body>
</html>
);
}
6 changes: 6 additions & 0 deletions app/page.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { style } from "@vanilla-extract/css";

export const container = style({
padding: 10,
background: "green",
});
230 changes: 0 additions & 230 deletions app/page.module.css

This file was deleted.

3 changes: 2 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";
import * as styles from "./page.css";

const Home = () => {
return <div />;
return <div className={styles.container}>hello</div>;
};

export default Home;
Empty file added components/.gitkeep
Empty file.
20 changes: 20 additions & 0 deletions config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
interface Config {
baseURL: string;
nodeEnv: "development" | "production" | "test";
clientUrl: string;
serviceName: string;
}

const createConfig: () => Config = () => {
if (!process.env.NEXT_PUBLIC_SERVER_URL) throw new Error("no api server url");
if (!process.env.NODE_ENV) throw new Error("no node env");

return {
baseURL: process.env.NEXT_PUBLIC_SERVER_URL,
nodeEnv: process.env.NODE_ENV,
clientUrl: typeof window !== "undefined" ? window.location.origin : "",
serviceName: "부마위키",
};
};

export default createConfig();
7 changes: 7 additions & 0 deletions constants/authority.constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const authority = {
ADMIN: "ADMIN",
READONLY: "BANNED",
USER: "USER",
};

export default authority;
24 changes: 24 additions & 0 deletions constants/exception.constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const exception = {
code: {
IMG_400_1: "IMG-400-1",
DOCS_404_1: "DOCS-404-1",
DOCS_404_2: "DOCS-404-2",
DOCS_403_1: "DOCS-403-1",
COMMON_403_1: "COMMON-403-1",
USER_403_1: "USER-403-1",
DOCS_403_2: "DOCS-403-2",
TOKEN_403_1: "TOKEN-403-1",
TOKEN_403_2: "TOKEN-403-2",
TOKEN_403_3: "TOKEN-403-3",
USER_404_1: "USER-404-1",
},
status: {
SUCCESS: 200,
NOT_FOUND: 404,
FORBIDDEN: 403,
BAD_REQUEST: 400,
SERVER_ERROR: 500,
},
};

export default exception;
14 changes: 14 additions & 0 deletions context/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Contribute from "@/types/contribute.interface";
import { atom } from "jotai";

export const userContext = atom({
key: "userContext",
default: {
id: 0,
email: "",
nickName: "",
authority: "",
contributeDocs: [] as Array<Contribute>,
isLogin: false,
},
});
Empty file added hooks/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions provider/LayoutProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const LayoutProvider = ({ children }: React.PropsWithChildren) => {
return <>{children}</>;
};

export default LayoutProvider;
Comment on lines +1 to +5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LayoutProvider의 존재 이유가 궁금합니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LayoutProvider는 아직 작성된 레이아웃이 없어 빈 프레임을 사용했습니다!
보통 공통적으로 들어가는 레이아웃이나 형식을 지정할 때 사용하려고 생각 중입니다!
제가 진행했던 BSM 서비스에서는 다음과 같이 사용합니다😀

import "react-toastify/dist/ReactToastify.css";
import { ToastContainer, toast } from "react-toastify";
import styled from "styled-components";
import { Footer, Header } from "@/components/common";
import { GlobalStyle, flex } from "@/styles";
import Modal from "@/@modal/layouts";

const LayoutProvider = ({ children }: React.PropsWithChildren) => {
  return (
    <>
      <StyledToastify autoClose={1000} position={toast.POSITION.TOP_RIGHT} />
      <GlobalStyle />
      <Modal />
      <Layout>
        <Header />
        <Main>{children}</Main>
        <Footer />
      </Layout>
    </>
  );
};

const StyledToastify = styled(ToastContainer)`
  .Toastify__toast {
    color: black;
    font-size: 14px;
  }
`;

const Layout = styled.div`
  ${flex.COLUMN_FLEX};
  gap: 6vh;
`;

const Main = styled.main`
  ${flex.FLEX};
  gap: 14px;
  width: 100%;
  padding: 0 8vw;
  min-height: 52vh;
`;

export default LayoutProvider;

19 changes: 19 additions & 0 deletions provider/ReactQueryProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
enabled: true,
retry: 0,
},
},
});

const ReactQueryProvider = ({ children }: React.PropsWithChildren) => {
return (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);
};

export default ReactQueryProvider;
16 changes: 16 additions & 0 deletions provider/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { PropsWithChildren } from "react";
import { Provider as JotaiProvider } from "jotai";
import ReactQueryProvider from "./ReactQueryProvider";
import LayoutProvider from "./LayoutProvider";

const AppProvider = ({ children }: PropsWithChildren) => {
return (
<ReactQueryProvider>
<JotaiProvider>
<LayoutProvider>{children}</LayoutProvider>
</JotaiProvider>
</ReactQueryProvider>
);
};

export default AppProvider;
Empty file added public/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.

Empty file added services/.gitkeep
Empty file.
Loading