/sq-intern-practice-ground

๐Ÿ“– ์ธํ„ด์ƒํ™œ ์ค‘ ์—…๋ฌด๊ด€๋ จ ์ด์Šˆ์ •๋ฆฌ ๋ฐ ์—ฐ์Šต์šฉ ์ €์žฅ์†Œ

Primary LanguageTypeScript



๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป
Intern : Practice Ground






์—…๋ฌด๊ด€๋ จ ์Šคํ„ฐ๋””๊ฐ€ ํ•„์š”ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ์—ฐ์Šต์šฉ ์ €์žฅ์†Œ. 2020.03.02 ~ 2020.06.30
๋””๋ ‰ํ† ๋ฆฌ ๋ณ„๋กœ ๋‹ด๋‹นํ–ˆ๋˜ ์—…๋ฌด, ํ•ด๋‹น ์—…๋ฌด์—์„œ ํ•„์š”ํ–ˆ๋˜ ์Šคํ„ฐ๋”” ๊ธฐ๋กํ•˜๊ธฐ




Typescript

CL: Routing code base restructuring
์Šคํ„ฐ๋””: ์ž‘์—… ์ค‘ TS object ์ฐธ์กฐ ๊ด€๋ จ ์—๋Ÿฌ ํ•ธ๋“ค๋ง
https://cheatsheets.joshuatz.com/cheatsheets/typescript/
TS Error ํ•ธ๋“ค๋ง ์ค‘ Top-down์‹ ๋Œ€์ฒ˜๋ง๊ณ  Bottom-up์œผ๋กœ ์ œ๋Œ€๋กœ ๊ณต๋ถ€ํ•ด์•ผ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์–ด์„œ ์Šคํ„ฐ๋”” ์‹œ์ž‘
์ปจ์…‰์ด ํ™•์—ฐํžˆ ๋“ค์–ด๋‚  ์ˆ˜ ์žˆ๋Š” micro ์˜ˆ์‹œ ์ค‘์‹ฌ์œผ๋กœ ์ •๋ฆฌํ•  ์˜ˆ์ •


Gerrit

https://github.com/purelledhand/sq-intern-practice-ground/blob/master/gerrit/README.md
๋ชจ๋…ธ๋ ˆํฌ๊ธฐ๋ฐ˜์— ๋ธŒ๋žœ์น˜๋ฅผ ๋”ฐ์ง€ ์•Š์œผ๋ฉฐ gerrit ๊ธฐ๋ฐ˜์œผ๋กœ ์ฝ”๋“œ๋ฆฌ๋ทฐ๋ฅผ ์ง„ํ–‰ํ•˜๋Š” ํ™˜๊ฒฝ์— ์ ์‘ํ•˜๋ฉด์„œ ๊ฒช์€ ์ด์Šˆ๋“ค์„ ์œ„ ๋งํฌ์— ์ •๋ฆฌํ•ด ๋†“์•˜๋‹ค.
์ •๋ฆฌํ•œ ์ด์Šˆ๋“ค ๐Ÿฅ
1. Gerrit ๋ฐ Jenkins ํ™˜๊ฒฝ ์ •๋ฆฌ
2. Relation Chain๊ณผ Jenkins ๋ฐฐํฌ ๊ด€๋ จ ์ด์Šˆ
3. ๋กœ์ปฌ์—์„œ ์Œ“์ธ Relation Chain ๋น„์šฐ๊ธฐ


react-hook-form์„ ์ด์šฉํ•œ ํผ ์œ ํšจ์„ฑ ๊ฒ€์ฆ
React-Hook-Form + MUI ๋„์ž… ์•ˆ์ •์„ฑ ํ…Œ์ŠคํŠธ)

CL: Add AddUserDialog Component in Users page
์ƒˆ๋กœ ๋งก๊ณ  ์žˆ๋Š” ์—…๋ฌด์—์„œ form๊ณผ ๊ด€๋ จํ•˜์—ฌ react-hook-form ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋„์ž…์„ ์ œ์•ˆํ–ˆ๋‹ค.
๋‹ค์–‘ํ•œ handler ํ•จ์ˆ˜๋“ค์„ useForm ํ›…์„ ํ†ตํ•ด ์ œ๊ณตํ•ด์ฃผ๊ธฐ๋„ ํ•˜๊ณ , Typescript์œผ๋กœ ์ œ์ž‘๋˜์–ด์„œ ํผ ๋‚ด ๊ฐ value type์— ๋Œ€ํ•ด typesafeํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋ Œ๋”๋ง ํšŸ์ˆ˜ ๋ฐ ๋งˆ์šดํŠธ ์‹œ๊ฐ„๋„ ๋‹ค๋ฅธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ๋น„ํ•ด ํ›จ์”ฌ ์ž˜ ์ตœ์ ํ™”๋˜์–ด์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
์‹œ๋‹ˆ์–ด ์—”์ง€๋‹ˆ์–ด ๋ถ„๊ป˜์„œ๋Š” ๊ฐœ๋ฐœ์ด ๊ฐ„ํŽธํ•ด์ง€๋Š” ์ด์ ์ด ์žˆ๋‹ค๋ฉด ์ฐฌ์„ฑํ•˜์ง€๋งŒ, ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์—์„œ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” MUI ์ปดํฌ๋„ŒํŠธ์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๋ฐ์—๋„ ์ง€์žฅ์ด ์—†๋Š”์ง€ ์—ฌ์ญค๋ณด์…จ๋‹ค.
Contents
1. ๊ทธ๋ž˜์„œ MUI ์ปดํฌ๋„ŒํŠธ ํผ๊ณผ react-hook-form ์‚ฌ์šฉ์ด ์šฉ์ดํ•œ์ง€ ํ™•์ธํ•ด๋ณด๋Š” ํ…Œ์ŠคํŠธ์šฉ ํ”„๋กœ์ ํŠธ
2. native select tag์— inputRef๊ฐ€ ์ง์ ‘ ์ ์šฉ๋˜์ง€ ์•Š๋Š” MUI select ํƒœ๊ทธ์—์„œ value๊ฐ’์„ registerํ•˜๊ณ  ์ƒํƒœ๊ด€๋ฆฌ ์—†์ด ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๋ฒ•
3. password validation


Snackbar with notistack

CL: Add Snackbar component and use-case in login page
snackbar ๋˜๋Š” toast๋ฅผ ์Œ“์•„์„œ ๋””์Šคํ”Œ๋ ˆ์ดํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์ปค์Šคํ…€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ notistack์„ ์‚ฌ์šฉํ•˜์—ฌ ์ปดํฌ๋„ŒํŠธํ™”ํ–ˆ๋‹ค.
https://iamhosseindhv.com/notistack


gRPC ํ™˜๊ฒฝ์—์„œ protobufjs ์‚ฌ์šฉํ•˜๊ธฐ

์ด ๊ณณ์€ ์„œ๋ฒ„ ํ™˜๊ฒฝ์ด MSA๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์–ด์„œ internal ํ†ต์‹ ์˜ ์†๋„ ํ–ฅ์ƒ์„ ์œ„ํ•ด gRPC๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
๋•Œ๋ฌธ์— ํด๋ผ์ด์–ธํŠธ๋„ protobuf ๊ธฐ๋ฐ˜์œผ๋กœ ํ†ต์‹ ์„ ํ•˜๋Š”๋ฐ, ์„œ๋ฒ„์—์„œ gRPC-gateway๋ฅผ ์ œ๊ณตํ•˜๊ธฐ ๋•Œ๋ฌธ์— JSON์œผ๋กœ๋„ ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
ํ˜„์žฌ ๊ฐœ๋ฐœ์ค‘์ธ ์„œ๋น„์Šค๋Š” ๋ฐฑ์˜คํ”ผ์Šค ์„œ๋น„์Šค์ด๊ธฐ ๋•Œ๋ฌธ์— ํ†ต์‹  ์†๋„์˜ ์ค‘์š”์„ฑ์ด ๋‹ค๋ฅธ ํ”„๋กœ๋•ํŠธ๋“ค์— ๋น„ํ•ด์„œ ๋‚ฎ์€ ํŽธ์ด๋ผ JSON์œผ๋กœ ์„œ๋ฒ„์— ์š”์ฒญํ•˜๊ธฐ๋กœ ์„ค๊ณ„๋˜์—ˆ๋Š”๋ฐ,
xprotobuf/JSON ๋“ฑ์˜ ์š”์ฒญ ํฌ๋งท๋ฟ๋งŒ์ด ์•„๋‹ˆ๋ผ TypeScript ์ œ๋„ˆ๋ฆญ ์‚ฌ์šฉ ๋“ฑ์—๋„ protobuf๊ฐ€ ์‚ฌ์šฉ๋˜์—ˆ๋‹ค.
gRPC๋กœ JSON์„ ์š”์ฒญํ•˜๊ณ  ๋”ฐ๋กœ protobuf๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ํ†ต์‹  ์†๋„์—๋Š” ์ „ํ˜€ ์ด์ ์ด ์—†๋Š”๋ฐ, ์™œ protobuf๊ฐ€ ์‚ฌ์šฉ๋˜๋Š”์ง€ ๊ถ๊ธˆํ–ˆ๋‹ค.
๊ฐ€์žฅ ํฐ ์ด์œ ๋Š” IDL ์ •์˜์™€ ์„œ๋ฒ„์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์ •์˜๋ฅผ ํด๋ผ์ด์–ธํŠธ์—์„œ๋„ ๊ณตํ†ต์ ์œผ๋กœ ์‚ฌ์šฉํ•˜์—ฌ source of truth๋ฅผ ํ•˜๋‚˜๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•จ์ด์—ˆ๋‹ค.
์ถ”๊ฐ€๋กœ TypeScript์™€ ํ•จ๊ป˜ ์“ฐ๋Š”๋ฐ ์žˆ์–ด ์ •๋ง ์ข‹์€ ์กฐํ•ฉ์ด๋ผ๊ณ  ์ƒ๊ฐ๋œ๋‹ค.
yarn protoc ์ปค๋งจ๋“œ์— ์•„๋ž˜ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋„ฃ์–ด์ฃผ๊ณ , smoke, deploy, test ์ปค๋งจ๋“œ์— yarn protoc๋ฅผ ์ถ”๊ฐ€์‹œ์ผœ์ฃผ์—ˆ๋‹ค.
$ pbjs --keep-case -t static-module -w es6 -o src/model/proto/index.js externalProto/**/*.proto && pbts -o src/model/proto/index.d.ts src/model/proto/index.js