C.W.K.
Stream
Lesson 06 of 07 · published

Node.js 와 Bun: Backend TS

~8 min · frameworks, node, bun, backend

Level 0Curious
0 XP0/93 lessons0/23 achievements
0/100 XP to next level100 XP to go0% complete
"Backend TypeScript: runtime 고르고, 코드 쓰고, 별도로 타입 체크."

Node + tsx vs Bun

Backend 의 TypeScript 엔 2026 의 2 실용 경로:

Node + tsx: `tsx` wrapper 와 Node.js (`npx tsx server.ts`). Tsx 가 내부적으로 esbuild 써서 on the fly 로 transpile. 모든 Node-호환 library 와 작동; dev 경험이 타입 체크 위한 `tsc --noEmit` 통해 통합.

Bun: Native TypeScript runtime (`bun run server.ts`). 더 빠른 startup, 내장 test runner, bundler, package manager. 대부분 Node-호환 library 작동; 일부 Node internal 이 adapter 필요.

TypeScript 와 Express/Fastify/Hono

인기 Node framework 다 first-class TypeScript 타입 가짐. Express 가 `@types/express` 필요; Fastify 와 Hono 가 자기 타입 ship.

Hono 가 새 lightweight 경쟁자 — edge (Cloudflare Worker, Bun, Deno) 용 설계, TypeScript-first. Route handler 가 그것의 validation middleware 쓸 때 추론된 parameter 와 body 타입 가짐.

공유 모양

어느 거 고르든 TypeScript 이야기 같음: `.ts` 쓰고, TS-aware runtime/wrapper 로 돌리고, 별도로 타입-체크. 차이가 속도, library 호환, ergonomics — type system 아님.

2026 의 새 backend TS 엔 속도엔 Bun + Hono, 호환엔 Node + Express 가 default. 둘 다 유효; 선택이 프로젝트의 다른 제약에 달림.

Code

최소 Hono + Bun server·typescript
// Hono + Bun — modern 최소 예시.
import { Hono } from 'hono';

const app = new Hono();

app.get('/', (c) => c.text('Hello from Hono'));

app.get('/users/:id', (c) => {
  const id = c.req.param('id');     // id: string — 타입 붙음
  return c.json({ id, name: `User ${id}` });
});

export default app;

// 실행: bun run server.ts
// 또는 Node + tsx: npx tsx server.ts (Hono 가 둘 다 작동)
Express + Node + tsx — 자리잡은 stack·typescript
// Express + Node + tsx — classic stack.
import express, { Request, Response } from 'express';

const app = express();
app.use(express.json());

app.get('/users/:id', (req: Request<{ id: string }>, res: Response) => {
  const { id } = req.params;     // id: string
  res.json({ id, name: `User ${id}` });
});

app.listen(3000);

// 실행: npx tsx server.ts
// 또는 먼저 build: npx tsc && node dist/server.js

External links

Exercise

TypeScript 로 'hello world' HTTP server 빌드. 두 번 시도: 한 번 Bun + Hono, 한 번 Node + tsx + Express. Startup 시간 측정. 어느 것의 타입이 더 깨끗히 느끼는지 적어.
Hint
Bun 의 startup 이 일관되게 빠름 — 작은 server 엔 자주 눈에 띔. Hono 의 API 가 Express 의 것보다 footgun 적음 (express.Request<{ id: string }> 가 까다로울 수). 새 코드엔 Hono 가 modern default; 기존 투자 있으면 Express 괜찮음.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.