Skip to content

Latest commit

ย 

History

History

week2-1

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
ย 
ย 
ย 
ย 

2์ฃผ์ฐจ IoT ์Šคํ„ฐ๋”” - ๋ชจ๊ฐ์ฝ”

๊ฐœ์š”

์ฃผ์ฐจ: 2์ฃผ์ฐจ ๋ชจ๊ฐ์ฝ”
๋‚ ์งœ: 2023๋…„ 4์›” 6์ผ ๋ชฉ์š”์ผ 18:30 ~ 21:00
์žฅ์†Œ: ๊ตญ๋ฏผ๋Œ€ํ•™๊ต ๋ฏธ๋ž˜๊ด€ 445ํ˜ธ
์ฃผ์ œ: 1. Server - Node.js ์ž…๋ฌธ
์ฐธ์—ฌ: IoT ์Šคํ„ฐ๋”” ๋ฐ CV ์Šคํ„ฐ๋”” ์ฐธ์—ฌ์ž 22๋ช…
๋ฉ˜ํ† : ์œค๋ฏผ์šฐ, ์ด์ค€ํ˜, ์œค์‹ ์ง€

์ง„ํ–‰ ๋ฐฉ์‹

  1. ๋ชจ๊ฐ์ฝ” ์กฐ๋ผ๋ฆฌ ๋ชจ์ž…๋‹ˆ๋‹ค.
  2. ๋ชจ๊ฐ์ฝ” ์กฐ๋ผ๋ฆฌ ํ•จ๊ป˜ ๊ฐ•์˜ ์ž๋ฃŒ๋ฅผ ๋ณด๋ฉด์„œ ๊ณต๋ถ€๋ฅผ ์ง„ํ–‰ํ•˜๊ณ , ์ œ๊ณต๋œ ๊ณผ์ œ๋ฅผ ๊ฐ™์ด ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
  3. ๋งŒ์•ฝ ์งˆ๋ฌธ์ด ์žˆ๋‹ค๋ฉด, ๋ฉ˜ํ† ๋ฅผ ๋ถˆ๋Ÿฌ์ฃผ์„ธ์š”! ๋งŒ์•ฝ, ๋ฉ˜ํ† ๊ฐ€ ์—†๋‹ค๋ฉด ์˜จ๋ผ์ธ ์งˆ๋ฌธ ๋ฐฉ๋ฒ•์„ ์ฐธ๊ณ ํ•˜์—ฌ GitHub Issue๋ฅผ ํ†ตํ•ด ์งˆ๋ฌธํ•ด์ฃผ์„ธ์š”!
  4. ๊ณผ์ œ ์ œ์ถœ ํฌ๋งท์„ ์ฐธ๊ณ ํ•˜์—ฌ ๊ณผ์ œ๋ฅผ ๊ฐ์ž ์ œ์ถœํ•ฉ๋‹ˆ๋‹ค.

๊ฐ•์˜ ์ž๋ฃŒ

ํ•œ์‹œ๊ฐ„๋งŒ์— Node.js ๋ฐฑ์—”๋“œ ๊ธฐ์ดˆ ๋๋‚ด๊ธฐ (ft. API ๊ตฌ์ถ•)

๊ณผ์ œ(~4/11)

์ œ๊ณต๋œ FrontEnd(React)ํŒŒ์ผ์„ ์‹คํ–‰์‹œํ‚ค๊ณ , ์•„๋ž˜์— ์žˆ๋Š” API ๋ช…์„ธ์„œ์— ๋”ฐ๋ผ BackEnd(Express Server)๋ฅผ ์ œ์ž‘ํ•˜์—ฌ ๊ณผ์ œ๋ฅผ ์ œ์ถœํ•ฉ๋‹ˆ๋‹ค. ๊ณผ์ œ ์ œ์ถœ ๋ฐฉ๋ฒ•์€ ๊ณผ์ œ ์ œ์ถœ ํฌ๋งท์„ ์ฐธ๊ณ ํ•˜์„ธ์š”!
์ œ๊ณต๋œ FrontEnd๋ฅผ ์‹คํ–‰์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ๋Š” Node.js(LTS ๋ฒ„์ „์„ ์ถ”์ฒœ) ์„ค์น˜ํ•˜๊ณ , React๋ฅผ ์„ค์น˜ํ•œ ์ดํ›„, npm install์„ ํ†ตํ•˜์—ฌ ๋ชจ๋“ˆ๋“ค์„ ์„ค์น˜ํ•˜๊ณ , npm start๋ฅผ ํ†ตํ•ด์„œ ์‹คํ–‰์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์„œ๋ฒ„๋Š” http://127.0.0.1:3000์— ์—ด๋ฆฌ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
๊ทธ๋ฆฌ๊ณ , ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ์ดํ„ฐ๋Š” ์•„๋ž˜์˜ ๋ฐ์ดํ„ฐ ํฌ๋งท๊ณผ ๊ฐ™์ด ํ•˜๋“œ์ฝ”๋”ฉ์„ ํ†ตํ•ด์„œ ์ €์žฅํ•˜๊ณ  FrontEnd์—์„œ GET ์š”์ฒญ์„ ํ•˜๋ฉด ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

API ๋ช…์„ธ์„œ

Index Method URI Data Format Description
1 GET /dust [{ team: "String Type Team Name", value: "Number Type Dust Value" }, { team: "๋ชจ๊ฐ์ฝ” 2์กฐ", value: "38" }] team ์ด๋ฆ„๊ณผ, value์— ๋ฏธ์„ธ๋จผ์ง€ ์ธก์ •๊ฐ’์„ ๋ณด๋‚ธ๋‹ค.
2 PATCH /toggle "ON" or "OFF" ๋ฒ„ํŠผ์„ ํ†ตํ•ด ON๊ณผ OFF๋ฅผ ์ œ์–ดํ•œ๋‹ค.

๋ฏธ๋ฆฌ ํ•ด๋ณด๋Š” ๊ณผ์ œ(~4/13)

ํ•ด๋‹น ๊ณผ์ œ๋„ ๋ชจ๊ฐ์ฝ” ์กฐ์™€ ํ•จ๊ป˜ํ•˜๋Š” ๊ณผ์ œ๋กœ, 11์ผ๋ถ€ํ„ฐ 13์ผ๊นŒ์ง€ ๊ธฐ๊ฐ„์ด ๋„ˆ๋ฌด ์งง๊ธฐ ๋•Œ๋ฌธ์— ๋ฏธ๋ฆฌ ๊ณต์ง€๋“œ๋ฆฝ๋‹ˆ๋‹ค! ๊ณผ์ œ๋ฅผ ๋ฏธ๋ฆฌ ์ œ์ถœํ•ด์ฃผ์…”๋„ ์ข‹๊ณ , 13์ผ๊นŒ์ง€ ์ œ์ถœํ•ด์ฃผ์…”๋„ ์ข‹์Šต๋‹ˆ๋‹ค.
์œ„์—์„œ๋Š” [{ team: "String Type Team Name", value: "Number Type Dust Value" }, { team: "๋ชจ๊ฐ์ฝ” 2์กฐ", value: "38" }]์„ ํ•˜๋“œ ์ฝ”๋”ฉ์„ ํ†ตํ•ด์„œ ์ €์žฅํ–ˆ์—ˆ๋Š”๋ฐ, ์ด๋ฒˆ์—” MongoDB(ํ˜น์€ MongoDB Atlas)์™€ Mongoose๋ฅผ Express ์„œ๋ฒ„์— ์ถ”๊ฐ€ํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ์žˆ๋Š” ์ •๋ณด๋“ค์„ findํ•˜์—ฌ ๋ฏธ์„ธ๋จผ์ง€ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ , ๊ทธ ์ •๋ณด๋ฅผ GET Method๊ฐ€ ๋™์ž‘ํ• ๋•Œ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“ค์–ด๋ณด์„ธ์š”!
๊ทธ๋ฆฌ๊ณ  Mongoose๋ฅผ ์‚ฌ์šฉํ• ๋•Œ ๋ฏผ๊ฐํ•œ ์ •๋ณด(์•„์ด๋””, ๋น„๋ฐ€๋ฒˆํ˜ธ)๊ฐ€ ํฌํ•จ๋˜๊ธฐ ๋•Œ๋ฌธ์—, GitHub์— ์ ˆ๋Œ€ ์˜ฌ๋ฆฌ์ง€ ๋งˆ์‹œ๊ณ  dotenv ๋ชจ๋“ˆ์„ ๊ณต๋ถ€ํ•˜์—ฌ dotenv๋ฅผ ํ†ตํ•ด์„œ ๋ฏผ๊ฐํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ ๊ณต๊ฐœ๋˜์ง€ ์•Š๊ฒŒ ๋งŒ๋“œ์„ธ์š”!
๊ณผ์ œ ์ œ์ถœ ๋ฐฉ๋ฒ•์€ ์œ„์™€ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.