Backend/NestJS(7)
-
ํธ๋์ญ์ ์๋ช ์ฃผ๊ธฐ ํ ์ ํจ์ฉ๊ณผ ํ์ฉ ๋ฐฉ์ (w/ NodeJS + TypeORM)
์๋ก ๋ฐฑ์๋ ์ ํ๋ฆฌ์ผ์ด์ ์์ ํธ๋์ญ์ ๊ด๋ฆฌ๋ ๋ฐ์ดํฐ ์ผ๊ด์ฑ์ ์ ์งํ๋ ํต์ฌ ์์์ ๋๋ค. Node.js ํ๊ฒฝ์์ TypeORM์ ์ฌ์ฉํ ๋, ์ฐ๋ฆฌ๋ ๊ธฐ๋ณธ์ ์ธ ํธ๋์ญ์ ๊ธฐ๋ฅ์ ์ฝ๊ฒ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ด ๋ณต์กํด์ง์๋ก, ๋จ์ํ ๋ฐ์ดํฐ๋ฒ ์ด์ค ํธ๋์ญ์ ์ด์์ ๊ฒ์ด ํ์ํด์ง๋๋ค.ํ๋ ์ ํ๋ฆฌ์ผ์ด์ ์์๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์์ ๊ณผ ํจ๊ป ์น์์ผ ํต์ , ํธ์ ์๋ฆผ, ์ธ๋ถ API ํธ์ถ ๋ฑ ๋ค์ํ ๋ถ๊ฐ ์์ ์ด ํ์ํฉ๋๋ค. ์ด๋ฌํ ์์ ๋ค์ DB ํธ๋์ญ์ ์ฑ๊ณต ์ฌ๋ถ์ ๋ฐ๋ผ ์คํ ์ฌ๋ถ๊ฐ ๊ฒฐ์ ๋๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ต๋๋ค. TypeORM์ ๊ธฐ๋ณธ ํธ๋์ญ์ API๋ง์ผ๋ก๋ ์ด๋ฌํ ๋ณต์กํ ํ๋ฆ์ ์ฐ์ํ๊ฒ ์ฒ๋ฆฌํ๊ธฐ ์ด๋ ต์ต๋๋ค.์ด ๊ธ์์๋ TypeORM ํ๊ฒฝ์์ ํธ๋์ญ์ ์๋ช ์ฃผ๊ธฐ ํ ์ ํ์ฉํด ํก๋จ ๊ด์ฌ์ฌ๋ฅผ ํจ๊ณผ์ ์ผ๋ก ์ฒ๋ฆฌํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์..
2025.04.28 -
NestJS Request Lifecycle (5) - Exception Filter
์ด์ ๊ธ 2022.12.22 - [Backend/NestJS] - NestJS Request Lifecycle (0) - ๊ฐ์ 2022.12.22 - [Backend/NestJS] - NestJS Request Lifecycle (1) - Middleware 2022.12.23 - [Backend/NestJS] - NestJS Request Lifecycle (2) - Guard 2022.12.26 - [Backend/NestJS] - NestJS Request Lifecycle (3) - Interceptor 2022.12.29 - [Backend/NestJS] - NestJS Request Lifecycle (4) - Pipe ์์ธ ํํฐ NestJS์์ ์์ธ ํํฐ๋ ๋น์ฆ๋์ค ๋ก์ง ๋ ๋ฒจ์์ ์ฒ๋ฆฌ๋์ง ์..
2023.01.13 -
NestJS Request Lifecycle (4) - Pipe
์ด์ ๊ธ 2022.12.22 - [Backend/NestJS] - NestJS Request Lifecycle (0) - ๊ฐ์ 2022.12.22 - [Backend/NestJS] - NestJS Request Lifecycle (1) - Middleware 2022.12.23 - [Backend/NestJS] - NestJS Request Lifecycle (2) - Guard 2022.12.26 - [Backend/NestJS] - NestJS Request Lifecycle (3) - Interceptor ํ์ดํ NestJS์์ ํ์ดํ๋ ์ปจํธ๋กค๋ฌ์ ์๋จ์์ ์ฌ์ฉ์์ ์์ฒญ์ ๋ํด ๋ค์์ ์ญํ ์ ์ํํ๋ ์๋ช ์ฃผ๊ธฐ๋ฅผ ์๋ฏธํ๋ค. ๋ณํ: ์ฌ์ฉ์์ ์์ฒญ ์ ๋ฐ์ดํฐ๋ฅผ ์ํ๋ ํํ๋ก ๋ณ๊ฒฝ ํ ์ปจํธ๋กค๋ฌ์ ๋๊ฒจ์ค๋ค...
2022.12.29 -
NestJS Request Lifecycle (3) - Interceptor
์ด์ ๊ธ 2022.12.22 - [Backend/NestJS] - NestJS Request Lifecycle (0) - ๊ฐ์ 2022.12.22 - [Backend/NestJS] - NestJS Request Lifecycle (1) - Middleware 2022.12.23 - [Backend/NestJS] - NestJS Request Lifecycle (2) - Guard ์ธํฐ์ ํฐ NestJS ๋ด์์ ์ธํฐ์ ํฐ๋ ์ปจํธ๋กค๋ฌ ์ , ํ์์ ๋ค์ํ ์ญํ ์ ํด์ฃผ๋ ์๋ช ์ฃผ๊ธฐ๋ฅผ ์๋ฏธํ๋ค. ๊ณต์๋ฌธ์์์ ์ค๋ช ํ๋ ์ธํฐ์ ํฐ๊ฐ ๊ตฌ์ฒด์ ์ผ๋ก ํ๋ ์ผ์ ๋ค์๊ณผ ๊ฐ๋ค. ๋ฉ์๋(์ปจํธ๋กค๋ฌ) ์คํ ์ , ํ์ ์ถ๊ฐ์ ์ธ ๋ก์ง ์ํ ํจ์์์ ๋ฐํ๋ ๊ฒฐ๊ณผ ๋ฐ ์์ธ์ ๋ํ ๋ณํ ๊ธฐ๋ณธ ํจ์ ๋์์ ํ์ฅ ํน์ ์กฐ๊ฑด ํ์์ ์์ ํ ํจ์์ ์ฌ์ ์..
2022.12.26 -
NestJS Request Lifecycle (2) - Guard
์ด์ ๊ธ 2022.12.22 - [Backend/NestJS] - NestJS Request Lifecycle (0) - ๊ฐ์ 2022.12.22 - [Backend/NestJS] - NestJS Request Lifecycle (1) - Middleware ๊ฐ๋ NestJS ๋ด์์ ๊ฐ๋๋ ์์ฒญ ์๋ช ์ฃผ๊ธฐ์์ ๋ฏธ๋ค์จ์ด์ ๋ค์ชฝ, ์ธํฐ์ ํฐ์ ์์ชฝ์ ์์นํ์ฌ ํน์ ๊ฒฝ๋ก๋ก์ ์์ฒญ์ ์น์ธํ ์ง ๋ง์ง์ ๋ํ ํ๋จ์ ๋ด๋ฆฌ๋ ์ญํ ์ ํ๋ค. Express๋ก ๋ก์ง์ ๊ฐ๋ฐํ๋ค๋ณด๋ฉด ์ฌ์ฉ์์ ๊ถํ์ ๋ฐ๋ฅธ ์ฒ๋ฆฌ๋ฅผ ๋ฏธ๋ค์จ์ด์์ ํ๋ ๊ฒฝ์ฐ๊ฐ ์ฆ์๋ฐ, NestJS์์๋ ์ด๋ฅผ ๊ฐ๋๋ผ๋ ์๋ช ์ฃผ๊ธฐ์์ ๋ฐ๋ก ์ฒ๋ฆฌ๋ฅผ ํด์ฃผ๋ ๊ฒ์ด๋ค. ๋ฏธ๋ค์จ์ด ๋์ ๊ฐ๋๋ฅผ ์ฌ์ฉํ๋ ์ด์ ? ๊ทธ๋ ๋ค๋ฉด NestJS์์๋ ์ ๊ตณ์ด ๊ฐ๋๋ฅผ ๋ฐ๋ก ๋๋ ๊ฒ์ผ๊น? NestJS ๊ณต..
2022.12.23 -
NestJS Request Lifecycle (1) - Middleware
์ด์ ๊ธ 2022.12.22 - [Backend/NestJS] - NestJS Request Lifecycle (0) - ๊ฐ์ ๋ฏธ๋ค์จ์ด ( in NestJS ) ๋ฏธ๋ค์จ์ด๋ NestJS ์์ฒญ ์๋ช ์ฃผ๊ธฐ์์ ํด๋ผ์ด์ธํธ๋ก๋ถํฐ ๋ค์ด์ค๋ request๊ฐ ๊ฐ์ฅ ๋จผ์ ์ฒ๋ฆฌ๋๋ ํธ๋ค๋ฌ์ด๋ค. Node.js์ Express๋ฅผ ๋ค๋ค๋ณด์๋ค๋ฉด ์ด๋ฏธ ์ต์ํ ๊ฐ๋ ์ธ๋ฐ, Express ๋ฏธ๋ค์จ์ด์์๋ request, response ๊ฐ์ฒด์ ๋๋ถ์ด ๋ค์ ๋ฏธ๋ค์จ์ด๋ ๋ผ์ฐํฐ๋ฅผ ํธ์ถํ๋ next() ํจ์๋ฅผ ๋ค๋ฃฐ ์ ์๋ค. app.use((req,res,next)=>{ console.log('Request is received...') next() // ์คํ ์์ ๋ค์ ๋ฏธ๋ค์จ์ด๋ก req,res ์ ๋ฌ }) ๋ฏธ๋ค์จ์ด ์์ฑ NestJS๋ ๊ธฐ๋ณธ์ ์ผ๋ก ..
2022.12.22