IdoCleanCode
article thumbnail
반응형

Express.js - Tutorial

 

Express.js - Node.js의 관계
Express.js - Node.js의 관계

 

Node.js

정의

  • Node.js는 Chrome V8 JavaScript 엔진으로 빌드된 JavaScript 런타임 환경으로, 서버 사이드 애플리케이션을 개발하는 데 사용 됩니다.

특징

  • 비동기 이벤트 기반, 단일 스레드 이벤트 루프, 높은 성능의 네트워크 애플리케이션 개발을 위한 플랫폼입니다.

 

Express.js

정의

  • Express.js는 Node.js를 위한 앱 애플리케이션 및 API를 빠르고 간판하게 개발할 수 있도록 도와주는 웹 프레임 워크 입니다.

 

특징

  • 라우팅 및 미들웨어 지원으로 요청과 응답을 효과적으로 처리 할 수 있습니다.
  • 정적파일 서비스, 템플릿 엔진, RESTful API 개발 등 다양한 기능을 제공합니다.
  • 미니멀하면서 유연한 설계로 필요한 기능을 선택적으로 추가할 수 있습니다.

 

Node.js 웹 서버 에제

// 파일명: server.js
const http = require('http');

const server = http.createServer((req, res) => {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello, Node.js!');
});

const port = 3000;
server.listen(port, () => {
    console.log(`Server is running on port ${port}`);
});

 

Express.js 웹 서버 예제

// 파일명: app.js
const express = require('express');
const app = express();

const port = 3000;

app.get('/', (req, res) => {
    res.send('Hello, Express.js!');
});

app.listen(port, () => {
    console.log(`Express app is running on port ${port}`);
});

 

Express.js의 예제가 더 간결하면서, 강력한 기능을 제공합니다.

 

관련 자료

Express.js - 정의와 특징

 

참고 자료

https://expressjs.com/

https://www.geeksforgeeks.org/express-js/?ref=dhm

https://wrtn.ai

https://chat.openai.com

 

반응형
profile

IdoCleanCode

@IdoCleanCode

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!