Skip to content

Commit a7f8839

Browse files
authored
[25.06.19 / TASK-207] Refactor - 프로젝트 전반 리팩토링 (#43)
1 parent 3aa6cff commit a7f8839

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+513
-482
lines changed

.env.sample

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
'.env.development (개발 환경), .env.production (배포 환경)'
22

33
NEXT_PUBLIC_BASE_URL=<'server url here'>
4-
NEXT_PUBLIC_VELOG_URL=https://velog.io
5-
NEXT_PUBLIC_ABORT_MS=<'abort time(ms) for fetch here'>
6-
NEXT_PUBLIC_SENTRY_AUTH_TOKEN=<'sentry auth token here'>
74
NEXT_PUBLIC_CHANNELTALK_PLUGIN_KEY=<'channelTalk plugin key here'>
85
NEXT_PUBLIC_GA_ID=<'Google Analytics ID here'>
9-
NEXT_PUBLIC_EVENT_LOG=<'Whether to send an event log here (true | false)'>
10-
NEXT_PUBLIC_SENTRY_DSN=<'sentry dsn here'>
11-
NEXT_PUBLIC_ARCADE_URL=<'how-to-use url here'>
6+
NEXT_PUBLIC_SENTRY_AUTH_TOKEN=<'sentry auth token here'>
7+
NEXT_PUBLIC_SENTRY_DSN=<'sentry dsn here'>

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ module.exports = {
2828
],
2929
rules: {
3030
'prettier/prettier': ['error', { printWidth: 100 }],
31-
'import/order': ['error', { groups: ['builtin', 'external', 'internal'] }],
31+
'import/order': [
32+
'error',
33+
{ groups: ['builtin', 'external', 'internal'], alphabetize: { order: 'asc' } },
34+
],
3235
'no-restricted-imports': ['warn', { patterns: ['../../*'] }],
3336
'react/react-in-jsx-scope': 'off',
3437
'testing-library/no-container': 'warn',

sentry.client.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
44

55
import * as Sentry from '@sentry/nextjs';
6-
import { env } from '@/constants';
6+
7+
import { ENVS } from '@/constants';
78

89
Sentry.init({
9-
dsn: env.SENTRY_DSN,
10+
dsn: ENVS.SENTRY_DSN,
1011
release: 'production',
1112

1213
// Add optional integrations for additional features
@@ -25,5 +26,5 @@ Sentry.init({
2526

2627
// Setting this option to true will print useful information to the console while you're setting up Sentry.
2728
debug: false,
28-
enabled: process.env.NODE_ENV === 'production',
29+
enabled: ENVS.NODE_ENV === 'production',
2930
});

sentry.edge.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
55

66
import * as Sentry from '@sentry/nextjs';
7-
import { env } from '@/constants';
7+
import { ENVS } from '@/constants';
88

99
Sentry.init({
10-
dsn: env.SENTRY_DSN,
10+
dsn: ENVS.SENTRY_DSN,
1111
release: 'production',
1212

1313
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
1414
tracesSampleRate: 0.05,
1515

1616
// Setting this option to true will print useful information to the console while you're setting up Sentry.
1717
debug: false,
18-
enabled: process.env.NODE_ENV === 'production',
18+
enabled: ENVS.NODE_ENV === 'production',
1919
});

sentry.server.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
44

55
import * as Sentry from '@sentry/nextjs';
6-
import { env } from '@/constants';
6+
import { ENVS } from '@/constants';
77

88
Sentry.init({
9-
dsn: env.SENTRY_DSN,
9+
dsn: ENVS.SENTRY_DSN,
1010
release: 'production',
1111

1212
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
1313
tracesSampleRate: 0.1,
1414

1515
// Setting this option to true will print useful information to the console while you're setting up Sentry.
1616
debug: false,
17-
enabled: process.env.NODE_ENV === 'production',
17+
enabled: ENVS.NODE_ENV === 'production',
1818
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render, RenderResult } from '@testing-library/react';
22
import { ReactElement } from 'react';
3-
import { QueryProvider } from '@/components';
3+
import { QueryProvider } from '@/app/components/Provider/QueryProvider';
44

55
export const renderWithQueryClient = (element: ReactElement): RenderResult =>
66
render(<QueryProvider>{element}</QueryProvider>);

src/__test__/login.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { userEvent } from '@testing-library/user-event';
21
import { act, screen } from '@testing-library/react';
3-
import { ToastContainer } from 'react-toastify';
2+
import { userEvent } from '@testing-library/user-event';
43
import { useRouter } from 'next/navigation';
5-
import { renderWithQueryClient } from '@/utils/componentUtil';
4+
import { ToastContainer } from 'react-toastify';
65
import { default as Login } from '@/app/(login)/page';
6+
import { renderWithQueryClient } from './instance.test';
77

88
jest.mock('next/navigation', () => ({
99
useRouter: jest.fn(),

src/__test__/main.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { screen, waitFor } from '@testing-library/react';
2-
import { renderWithQueryClient } from '@/utils/componentUtil';
32
import { Content } from '@/app/(auth-required)/main/Content';
4-
import { Header } from '@/app/(auth-required)/components/header';
3+
import { Header } from '@/app/components/Header';
4+
import { renderWithQueryClient } from './instance.test';
55

66
jest.mock('next/navigation', () => ({
77
useSearchParams: () => ({

src/apis/dashboard.request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { PostDetailDto, PostListDto, PostSummaryDto, TotalStatsDto } from '@/types';
21
import { PATHS, SidebarIdType } from '@/constants';
2+
import { PostDetailDto, PostListDto, PostSummaryDto, TotalStatsDto } from '@/types';
33

44
import { instance } from './instance.request';
55

src/apis/instance.request.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import returnFetch, { FetchArgs } from 'return-fetch';
2-
31
import { captureException, setContext } from '@sentry/nextjs';
2+
import returnFetch, { FetchArgs } from 'return-fetch';
3+
import { ENVS } from '@/constants';
44
import { ServerNotRespondingError } from '@/errors';
5-
import { env } from '@/constants';
5+
6+
const ABORT_MS = 10000;
67

78
type ErrorType = {
89
code: string;
@@ -27,7 +28,7 @@ const abortPolyfill = (ms: number) => {
2728
};
2829

2930
const fetch = returnFetch({
30-
baseUrl: env.BASE_URL,
31+
baseUrl: ENVS.BASE_URL,
3132
headers: {
3233
Accept: 'application/json',
3334
'Content-Type': 'application/json',
@@ -66,8 +67,8 @@ export const instance = async <I, R>(
6667
: init?.headers,
6768
body: init?.body ? JSON.stringify(init.body) : undefined,
6869
signal: AbortSignal.timeout
69-
? AbortSignal.timeout(Number(env.ABORT_MS))
70-
: abortPolyfill(Number(env.ABORT_MS)),
70+
? AbortSignal.timeout(Number(ABORT_MS))
71+
: abortPolyfill(Number(ABORT_MS)),
7172
credentials: 'include',
7273
cache: 'no-store',
7374
});

0 commit comments

Comments
 (0)