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

CM-171: ๐Ÿ“ฆ ๋ฐฑ์—”๋“œ ํ™˜๊ฒฝ ์„ค์ • (DB, swagger) #6

Merged
merged 9 commits into from
Dec 24, 2024

Conversation

jinwooseok
Copy link
Contributor

๐Ÿ”๏ธ ์ž‘์—… ์ƒ์„ธ ๋‚ด์šฉ

์ž‘์—… ๋‚ด์šฉ์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.

  • AWS RDS๋ฅผ ์ƒ์„ฑ ๋ฐ ๋ณด์•ˆ ๊ทœ์น™ ์„ค์ •
  • ๊ธฐ์กด์— ์ž‘์„ฑํ–ˆ๋˜ ERD๋ฅผ Schema๋กœ ํ…Œ์ด๋ธ” ์ƒ์„ฑ
  • Next.js ๋ฐฑ์—”๋“œ <-> MysqlDB ์—ฐ๋™ ๋ฐ ํ…Œ์ŠคํŠธ
  • next-swagger-doc ํŒจํ‚ค์ง€๋กœ swagger ์—ฐ๋™ ๋ฐ ํ…Œ์ŠคํŠธ

๐Ÿ™ ์š”์ฒญ ๋ฐ ์งˆ๋ฌธ์‚ฌํ•ญ

์š”์ฒญ ๋ฐ ์งˆ๋ฌธ์‚ฌํ•ญ์ด ์žˆ๋‹ค๋ฉด ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.

  • ์ด์Šˆ๊ฐ€ ์ข€ ์žˆ๋Š”๋ฐ์—ฌ..

image

image

์‹ค์ œ ์‹คํ–‰์—๋Š” ์ง€์žฅ์ด ์—†๊ณ  ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์—์„œ๋งŒ ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค..

  1. Next.js ๋Š” ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์•ฑ ์ „์ฒด์— React Strict Mode๋ฅผ ์‚ฌ์šฉํ•จ
  2. ์‚ฌ์šฉํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ swagger-ui-react ์—์„œ ๊ตฌ์‹ ๋ผ์ดํ”„์‚ฌ์ดํด ๋ฉ”์„œ๋“œ๊ฐ€ ์‚ฌ์šฉ๋จ

React Strict Mode๋Š” ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์—์„œ ์ž ์žฌ์ ์ธ ๋ฌธ์ œ๋ฅผ ๋ฐœ๊ฒฌํ•˜๊ฒŒ ๋„์™€์ฃผ๋Š”๊ฑด๋ฐ ์ œ๊ฐ€ ์‚ฌ์šฉํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์ด๊ฒƒ๊ณผ ์ถฉ๋Œํ•ด์„œ ์ž‘์€ ์˜ค๋ฅ˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

swagger-api/swagger-ui#10212

์ €ํฌ์™€ ๋˜‘๊ฐ™์€ ์ƒํ™ฉ๊ณผ ๋ฒ„์ „์ธ ๋ถ„์ด ์ด์Šˆ ์˜ฌ๋ ธ๋Š”๋ฐ ์•„์ง ํ•ด๊ฒฐ๋˜์ง€๋Š”..! ์•Š์€ ๋“ฏ ํ•ฉ๋‹ˆ๋‹ค..

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์€ 2๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค..

  1. swagger ์•ˆ์“ฐ๊ธฐ (๋‹ค๋ฅธ ๋„๊ตฌ๋ฅผ ์ฐพ์•„๋ณด๊ธฐ)
  2. react strict mode๋ฅผ ๋„๊ธฐ (Next.js์—์„œ ๊ถŒ์žฅํ•˜์ง€ ์•Š๋Š” ๋ถ€๋ถ„)
  3. ์˜ค๋ฅ˜๋ฅผ ๋ฌด์‹œํ•˜๊ณ  ์ง„ํ–‰ํ•˜๊ธฐ (์ž ์žฌ์ ์ธ ์˜ค๋ฅ˜๋ผ ๊ฐœ๋ฐœ์— ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ)

๐Ÿ“ท ์Šคํฌ๋ฆฐ์ƒท

๊ฐ„๋‹จํ•œ ์Šคํฌ๋ฆฐ์ƒท์„ ์ฒจ๋ถ€ํ•ด์ฃผ์„ธ์š”.

swagger ๊ฒฐ๊ณผ

image

db ์—ฐ๋™ ๊ฒฐ๊ณผ

image

- api/test ๋ฅผ ํ†ตํ•ด DB์—ฐ๊ฒฐ์„ ํ…Œ์ŠคํŠธ ๊ฐ€๋Šฅ
- reviewer์— ๋‚ด๊ฐ€ ๋น ์ ธ์žˆ์—ˆ์Œ
- config์— ๋’€๋˜ db.ts๋ฅผ ๊ตณ์ด config์— ๋‘˜ ํ•„์š” ์—†๋‹ค๊ณ  ํŒ๋‹จํ•จ
- swagger-ui-react, @types/swagger-ui-react, next-swagger-doc
- db.ts๊ฐ€ utils๋กœ ์ด๋™ํ•˜๋ฉด์„œ import ๋ถ€๋ถ„ ๋ณ€ํ™”
- route.tsx์—์„œ route.ts๋กœ ๋ณ€๊ฒฝ
@jinwooseok jinwooseok self-assigned this Dec 23, 2024
Copy link
Collaborator

@u0empty u0empty left a comment

Choose a reason for hiding this comment

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

์ž˜์€ ๋ชจ๋ฅด์ง€๋งŒ ๋•๋ถ„์— rds๊ฐ€ ๋ฌด์—‡์ธ์ง€ ์ฐพ์•„๋ดค๋„ค์š”.. ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค!

Comment on lines +1 to +14
'use client';

import SwaggerUI from 'swagger-ui-react';
import 'swagger-ui-react/swagger-ui.css';

type Props = {
spec: Record<string, any>,
};

function ReactSwagger({ spec }: Props) {
return <SwaggerUI spec={spec} />;
}

export default ReactSwagger;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Redoc์ด Swagger์— ๋น„ํ•ด UI๊ฐ€ ๊ดœ์ฐฎ๋‹ค๊ณ  ํ•˜๋Š”๋ฐ ๊ธฐ์ˆ ์ ์œผ๋กœ ๊ณต๋ถ€ํ•ด ๋ณผ ๊ฐ€์น˜๊ฐ€ ์žˆ๋‹ค๋ฉด ์š”๊ฑธ๋กœ ํ•จ ๋ฐ”๊ฟ”๋ณด๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ์„ ๊ฒƒ ๊ฐ™์œผ๋„ค์š”..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ํ•œ๋ฒˆ ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

@@ -0,0 +1,38 @@
import { createPool } from "mysql2";
import type { Pool } from "mysql2";
Copy link
Collaborator

Choose a reason for hiding this comment

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

import ๋ฐ‘์œผ๋กœ ํ•œ ์ค„ ๋„์›Œ์ฃผ๋Š”๊ฑฐ ์–ด๋– ์…”


export const getApiDocs = async () => {
const spec = createSwaggerSpec({
apiFolder: "app/api", // define api folder under app folder
Copy link
Collaborator

Choose a reason for hiding this comment

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

์‚ด์ง ์ง€ํ”ผํ‹ฐ ํ–ฅ๊ธฐ๊ฐ€ ๋‚˜๋Š”๋ฐ ์ฃผ์„์„ ํ•œ๊ธ€๋กœ ํ†ต์ผํ•˜๋Š” ๊ฑด ์–ด๋•Œ์š”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

next-swagger-doc์˜ ๋ฌธ์„œ๋ฅผ ๋”ฐ๋ผํ•œ๊ฑฐ๋ผ์„œ,, ์ฃผ์„์ด ๋‹ฌ๋ ค์žˆ์—ˆ์–ด์š”. ์ œ๊ฑฐํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

@u0empty u0empty added the chore New feature or request label Dec 24, 2024
@u0empty u0empty merged commit 01ceb8b into main Dec 24, 2024
@u0empty u0empty deleted the CM-171-backend-setting branch December 24, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants