ํฐ์คํ ๋ฆฌ ๋ทฐ
๐งฉ NestJS Platform Agnosticism – ํ๋ซํผ ๋ ๋ฆฝ์ ์ํคํ ์ฒ์ ํ
octo54 2025. 5. 21. 11:32๐งฉ NestJS Platform Agnosticism – ํ๋ซํผ ๋ ๋ฆฝ์ ์ํคํ ์ฒ์ ํ
NestJS๋ Node.js์ ๋ค์ํ ํ๋ซํผ(HTTP, WebSocket, GraphQL, Fastify ๋ฑ) ์์์ ์ผ๊ด๋ ๊ฐ๋ฐ ๊ฒฝํ์ ์ ๊ณตํ๋ ํ๋ซํผ ๋
๋ฆฝ์ ํ๋ ์์ํฌ์
๋๋ค.
์ด๋ฒ ๊ธ์ NestJS ๊ณต์ ๋ฌธ์ Platform Agnosticism์ ๊ธฐ๋ฐ์ผ๋ก,
๋ค์ํ ํ๋ซํผ์์ ๋์ผํ ์ฝ๋ ๊ตฌ์กฐ๋ก Nest ์ ํ๋ฆฌ์ผ์ด์
์ ์คํํ๋ ๋ฐฉ๋ฒ์ ์ค๋ช
ํฉ๋๋ค.
๐ก “NestJS๋ ๋จ์ํ HTTP ์๋ฒ ํ๋ ์์ํฌ๊ฐ ์๋๋ผ, ๋ค์ํ ํ๋ซํผ์ ์ถ์ํํ Application Framework์ ๋๋ค.”
โ NestJS๊ฐ ์ง์ํ๋ ํ๋ซํผ
NestJS๋ ๋ค์๊ณผ ๊ฐ์ ํ๋ซํผ์์ ๋์ํฉ๋๋ค:
ํ๋ซํผ ์ค๋ช
Express | ๊ธฐ๋ณธ ํ๋ซํผ, ๋๋ถ๋ถ์ Node.js ์ฑ์์ ์ฌ์ฉ๋จ |
Fastify | ๋ ๋น ๋ฅธ ์ฑ๋ฅ๊ณผ ๋ฎ์ ์ค๋ฒํค๋๋ฅผ ์ ๊ณตํ๋ ๊ฒฝ๋ ์น ํ๋ ์์ํฌ |
GraphQL | @nestjs/graphql ๋ชจ๋์ ํตํด GraphQL ์๋ฒ๋ก ์๋ |
WebSocket | @WebSocketGateway()๋ก ์ค์๊ฐ ์ด๋ฒคํธ ์ง์ |
gRPC | @GrpcMethod()์ ํตํด ๊ณ ์ฑ๋ฅ RPC ํต์ ์ง์ |
๐ ํ๋ซํผ์ ์ถ์ํํ ๊ตฌ์กฐ
NestJS๋ ํต์ฌ DI, ๋ชจ๋ ์์คํ , ๋ผ์ฐํ ๊ตฌ์กฐ๋ ์ ์งํ๋ฉด์ ํ๋ซํผ๋ง ๊ต์ฒดํ ์ ์์ต๋๋ค.
โ Express vs Fastify ์์
// main.ts (Express)
const app = await NestFactory.create(AppModule);
await app.listen(3000);
// main.ts (Fastify)
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter(),
);
await app.listen(3000);
โ AppModule, Controller, Service ๋ฑ์ ์์ ํ ๋์ผํฉ๋๋ค.
๋ฐ๋๋ ๊ฑด NestFactory.create()์ ๋ ๋ฒ์งธ ์ธ์ ๋ฟ!
ํ๋ซํผ ๋ ๋ฆฝ์ ์ธ ์ํคํ ์ฒ ๊ตฌ์กฐ๋ ๋๊ท๋ชจ ์๋น์ค ํ์ฅ๊ณผ ์ฑ๋ฅ ์ต์ ํ์ ํต์ฌ ์์์ ๋๋ค.
์ด ์ง์ ์ ๋ธ๋ก๊ทธ์์ ์ฑ๋ฅ ๊ฐ์ ๊ณผ ๊ธฐ์ ์ ํ์ ๋ฏผ๊ฐํ ๋ ์๋ค์ด ์ง์คํ๋ ๊ตฌ๊ฐ์ ๋๋ค.
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-XXXXXX"
data-ad-slot="YYYYYY"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
๐ Platform Adapter ํจํด
NestJS๋ ์ด๋ํฐ ํจํด์ ์ฌ์ฉํ์ฌ Express๋ Fastify ๊ฐ์ ํ๋ซํผ์ ์ข ์๋์ง ์๊ณ ์ฝ๋๋ฅผ ์คํํฉ๋๋ค.
โ ์ด๋ํฐ ์ข ๋ฅ
์ด๋ํฐ ์ค๋ช
ExpressAdapter | ๊ธฐ๋ณธ HTTP ์๋ฒ ์ด๋ํฐ |
FastifyAdapter | ๊ณ ์ฑ๋ฅ ์น ์๋ฒ ์ด๋ํฐ |
WsAdapter | WebSocket ๊ธฐ๋ฐ ์ค์๊ฐ ํต์ ์ด๋ํฐ |
GraphQLAdapter | GraphQL ํตํฉ์ฉ ์ด๋ํฐ (Apollo ๋ฑ) |
๐ ๏ธ ์ค์ ํ์ฉ ์ ๋ต
โ Fastify๋ก ์ฑ๋ฅ ์ต์ ํ
npm install --save @nestjs/platform-fastify fastify
// main.ts
import { NestFactory } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter(),
);
await app.listen(3000);
- Express๋ณด๋ค ์ต๋ 2~3๋ฐฐ ๋น ๋ฅธ ์๋ต ์๋ ํ๋ณด
- ๋ผ์ฐํ , ๋ฏธ๋ค์จ์ด, DI ๊ตฌ์กฐ๋ ๋์ผํ๊ฒ ์ ์ง
๐ ๋ฐํ์์ ํ๋ซํผ ๊ตฌ๋ถ – ์ค๋ฌด ํ
const app = process.env.USE_FASTIFY === 'true'
? await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter())
: await NestFactory.create(AppModule);
await app.listen(3000);
โ๏ธ ํ๊ฒฝ ๋ณ์๋ก ํ๋ซํผ์ ์ ํ ๊ฐ๋ฅ
โ๏ธ ํ ์คํธ ํ๊ฒฝ์ Express, ์ด์ ํ๊ฒฝ์ Fastify ์ ๋ต๋ ๊ฐ๋ฅ
๐ง ์ค๋ฌด ์ค๊ณ ์ ๋ต
์ ๋ต ์ค๋ช
Express → Fastify ์ ํ ์ค๋น | ํ๋ซํผ ์ถ์ํ ๊ตฌ์กฐ ์ ์ง๋ก ๊ต์ฒด๊ฐ ์ฉ์ดํจ |
HTTP + WebSocket ๋์ ์ฒ๋ฆฌ | ExpressAdapter + WsAdapter๋ก ๊ฐ๋ฅ |
GraphQL + REST ๊ณต์กด | ๋์ผ ๋ชจ๋ ๊ตฌ์กฐ ๋ด์ GraphQL Resolver + REST Controller ์ด์ |
Custom Adapter ๊ตฌ์ถ | ํน์ํ ๋คํธ์ํฌ/IoT ํ๊ฒฝ์์๋ ์์ฒด ์ด๋ํฐ ์ ์ ๊ฐ๋ฅ |
โ ํ๋ซํผ ๋ ๋ฆฝ ๊ตฌ์กฐ์ ์ด์
- โ ๋ง์ด๊ทธ๋ ์ด์ ์์ ๋ ํ๋ณด (Express → Fastify)
- โ ํ ์คํธ์ ์ด์ ํ๊ฒฝ ๋ถ๋ฆฌ ๊ฐ๋ฅ
- โ ์ฝ๋ ์ฌ์ฌ์ฉ์ฑ๊ณผ ํ์ฅ์ฑ ํฅ์
- โ ์ฑ๋ฅ ๊ฐ์ ์ ์ ๋ต ์ ํ ์ ์ฐํ
๐ ๋ง๋ฌด๋ฆฌ ์์ฝ
๊ฐ๋ ์ค๋ช
Platform Agnosticism | NestJS ์ฝ์ด๋ ํ๋ซํผ์ ๋ ๋ฆฝ์ ์ธ ๊ตฌ์กฐ๋ก ์ค๊ณ๋จ |
Adapter ํจํด | ํ๋ซํผ ๋ณ ์ด๋ํฐ๋ก ๊ต์ฒด ๊ฐ๋ฅ (Express, Fastify ๋ฑ) |
์ค๋ฌด ํ์ฉ ์ ๋ต | ์ฑ๋ฅ, ํ์ฅ์ฑ, ํ ์คํธ ๋ชฉ์ ์ ๋ง๊ฒ ํ๋ซํผ ๊ต์ฒด ๊ฐ๋ฅ |
NestJS Platform Agnosticism,NestJS Express vs Fastify,NestJS ์ด๋ํฐ ํจํด,NestJS Fastify ์ ์ฉ,NestJS ํ๋ซํผ ๋ ๋ฆฝ์ฑ,NestJS ์ฑ๋ฅ ์ต์ ํ,NestJS Adapter ๊ตฌ์กฐ,NestJS GraphQL REST ๊ณต์กด,NestJS HTTP WebSocket,NestJS ์ค๋ฌด ์ํคํ ์ฒ ์ค๊ณ
'framework > NestJS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
- Total
- Today
- Yesterday
- ํ๋ก ํธ์๋๋ฉด์
- CI/CD
- nextJS
- Python
- Prisma
- Docker
- ํ๋ก ํธ์๋
- llm
- gatsbyjs
- ๋ฐฑ์๋๊ฐ๋ฐ
- github
- Next.js
- ์น๊ฐ๋ฐ
- Webpack
- rag
- AI์ฑ๋ด
- App Router
- nodejs
- PostgreSQL
- seo ์ต์ ํ 10๊ฐ
- ๊ฐ๋ฐ๋ธ๋ก๊ทธ
- REACT
- kotlin
- ๋ฅ๋ฌ๋
- SEO ์ต์ ํ
- fastapi
- SEO์ต์ ํ
- ํ์ด์ฌ ์๊ณ ๋ฆฌ์ฆ
- Ktor
- NestJS
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |