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

πŸ“ [Docs] nest.js app μ‹€ν–‰ 방법 #36

Closed
jis-kim opened this issue Apr 7, 2023 · 3 comments
Closed

πŸ“ [Docs] nest.js app μ‹€ν–‰ 방법 #36

jis-kim opened this issue Apr 7, 2023 · 3 comments
Assignees
Labels
backend issue for backend documentation Improvements or additions to documentation

Comments

@jis-kim
Copy link
Contributor

jis-kim commented Apr 7, 2023

nest.js app 초기 μ‹€ν–‰

backend 디렉토리 μ•ˆμ—μ„œ μ‹€ν–‰ν•΄μ£Όμ„Έμš”.

  • .env.sample 파일 μ°Έκ³ ν•΄μ„œ .env 파일 μž‘μ„±
    • db host 와 app url은 일단 "localhost" 둜 μž‘μ„±ν•΄μ£Όμ„Έμš”
  • yarn install
  • yarn db
  • psql -U [username] -d [dbname] -h [dbhost] -p [dbport] -f ../database/create-table.sql
    • psql 은 μ„€μΉ˜κ°€ ν•„μš”ν•  수 μžˆμŠ΅λ‹ˆλ‹€. brew install libpq
  • yarn start:prod λ˜λŠ” yarn start:dev
    • yarn start:prod : NODE_ENV=production ν™˜κ²½λ³€μˆ˜ μ„€μ •ν•΄μ„œ ν΄λΌμ΄μ–ΈνŠΈκ°€ Authorization header둜 'token' λ‹΄μ•„μ„œ 톡신할 λ•Œ μ‚¬μš©
    • yarn start:dev : NODE_ENV=development ν™˜κ²½λ³€μˆ˜ μ„€μ •ν•΄μ„œ ν΄λΌμ΄μ–ΈνŠΈκ°€ x-my-id header둜 'user id' λ‹΄μ•„μ„œ 톡신할 λ•Œ μ‚¬μš©

DB ν…Œμ΄λΈ”μ΄ μ‘΄μž¬ν•˜λŠ” μƒνƒœμ—μ„œ μ‹€ν–‰

  • psql μ‹€ν–‰ 없이 yarn db ν›„ λ°”λ‘œ yarn run start ν•΄μ£Όμ‹œλ©΄ λ©λ‹ˆλ‹€.
  • yarn db:reset 으둜 λ³Όλ₯¨μ„ μ‚­μ œν•˜κ³  λ‹€μ‹œ 초기 μ‹€ν–‰ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

DB seeding

  • .env νŒŒμΌμ— TEST_DB_NAME μ„€μ • λ˜μ—ˆλŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€. (ν•΄λ‹Ή ν™˜κ²½λ³€μˆ˜λ₯Ό μ½μ–΄μ„œ μ‹€ν–‰ν•©λ‹ˆλ‹€.)

  • yarn seed:reset && yarn seed [number]

    • yarn seed:reset μ‹œ ν…ŒμŠ€νŠΈ λ°μ΄ν„°λ² μ΄μŠ€κ°€ λ‚ μ•„κ°”λ‹€κ°€ λ‹€μ‹œ μƒμ„±λ˜λ―€λ‘œ μ‚¬μš©μ— μ£Όμ˜ν•΄μ£Όμ„Έμš”!
    • [number] μžλ¦¬μ—λŠ” μƒμ„±ν•˜κ³ μž ν•˜λŠ” auth 의 row 수λ₯Ό μž…λ ₯ν•©λ‹ˆλ‹€. ν™•λ₯ μ— 따라 user, friendship, message κ°€ μ°¨λ‘€λ‘œ μƒμ„±λ©λ‹ˆλ‹€.
    • μƒμ„±λœ λ°μ΄ν„°λŠ” backend/seeding/results/[tableλͺ…].json μ—μ„œ 파일둜 확인 κ°€λŠ₯ν•©λ‹ˆλ‹€.
  • μ‹€ν–‰ κ²°κ³Ό
    Screenshot 2023-04-18 at 6 48 13 PM

  • auth
    Screenshot 2023-04-18 at 8 42 15 PM

  • user
    Screenshot 2023-04-18 at 8 42 57 PM

  • friend
    Screenshot 2023-04-18 at 8 52 08 PM

  • message
    Screenshot 2023-04-18 at 8 51 38 PM

Swagger

  • nest app μ‹€ν–‰ν•΄μ£Όμ‹œκ³  localhost:${APP_PORT}/api 둜 μ ‘μ†ν•˜μ‹œλ©΄ swagger 둜 ν…ŒμŠ€νŠΈ ν•˜μ‹€ 수 μžˆμŠ΅λ‹ˆλ‹€.
@jis-kim jis-kim added documentation Improvements or additions to documentation backend issue for backend labels Apr 7, 2023
@jis-kim jis-kim self-assigned this Apr 7, 2023
@jis-kim jis-kim pinned this issue Apr 7, 2023
@nyeoni
Copy link
Member

nyeoni commented Apr 23, 2023

brew install psql 이 μ•„λ‹Œ brew install libpq 인 것 κ°™μŠ΅λ‹ˆλ‹€. 이 λΆ€λΆ„ μˆ˜μ •ν•΄μ£Όμ‹œλ©΄ κ°μ‚¬ν•˜κ² μŠ΅λ‹ˆλ‹Ή :)

μ €λŠ” μ•„λž˜ μˆœμ„œλ‘œ μ„€μΉ˜ μ§„ν–‰ν•˜μ˜€μŠ΅λ‹ˆλ‹€

brew install libpq
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

@Kimhan-nah
Copy link
Member

psql -U [username] -d [dbname] -h [dbhost] -f ../database/create-table.sql μ—μ„œ
psql -U [username] -d [dbname] -h [dbhost] -p [dbport] -f ../database/create-table.sql 둜 μˆ˜μ • ν•„μš”ν•  κ±° κ°™μ•„μš” πŸ€“

@jis-kim
Copy link
Contributor Author

jis-kim commented Apr 25, 2023

@Kimhan-nah μˆ˜μ •ν•˜κ² μŠ΅λ‹ˆλ‹€ κ³ λ§™μŠ΅λ‹ˆλ‹€~! μ €λŠ” λ‘œμ»¬μ—μ„œ μ‹€ν–‰ν•˜λ‹€λ³΄λ‹ˆ λ†“μΉœμ μ΄ κ½€ λ§Žλ„€μš”

@nyeoni nyeoni closed this as completed May 29, 2023
@jis-kim jis-kim unpinned this issue Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend issue for backend documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants