Express는 Node.js에서 서버를 쉽게 만들 수 있도록 도와주는 웹 프레임워크야.
Node.js는 원래 웹 서버 기능이 있지만, 직접 만들면 복잡하고 귀찮아. 그래서 Express는 이런 걸 더 간단하게 처리할 수 있게 도와주는 라이브러리야.
http 모듈 없이도 요청/응답 쉽게 처리 가능GET, POST 등) 간단하게 처리 가능npm install express
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("Hello Express!");
});
app.listen(3000, () => {
console.log("서버 실행 중...");
});
| 기능 | 설명 |
|---|---|
app.get() |
GET 요청 처리 |
app.post() |
POST 요청 처리 |
app.use() |
미들웨어 등록 (예: bodyParser, 라우터 등) |
express.Router() |
라우팅 분리해서 관리 가능 |
express.json() |
JSON 데이터 파싱 미들웨어 |
express.urlencoded() |
폼 데이터 파싱 미들웨어 |
필요하면 express.Router() 구조나 REST API 설계 흐름도 같이 설명해줄게!