1. Express
Node.js를 위한 가벼운 웹 애플리케이션 프레임워크, 빠르게 API 개발이 가능
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`));
2. Axios
Promise 기반의 HTTP 요청 라이브러리
const axios = require('axios');
axios.get('https://api.example.com/data')
.then(response => console.log(response.data))
.catch(error => console.log(error));
3. Socket.io
웹 소켓을 위한 라이브러리, 실시간 애플리케이션 개발 및 채팅 기능 구현에 사용
const app = require('express')();
const http = require('http').Server(app);
const io = require('socket.io')(http);
app.get('/', (req, res) => res.sendFile(__dirname + '/index.html'));
io.on('connection', socket => {
socket.on('chat message', msg => io.emit('chat message', msg));
});
http.listen(3000, () => console.log('listening on *:3000'));
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
// ...
</script>
4. Moment
Node.js에서 다양한 날짜 및 시간 형식을 처리하기 위한 라이브러리
const moment = require('moment')
// 날짜 및 시간 format 변경
const now = moment()
console.log(now.format('MMMM Do YYYY, h:mm:ss a')) // june 13th 2023, 11:46:05 am
5. Nodemon
개발 환경에서 Node.js 애플리케이션을 자동으로 재시작해 주는 도구
// package.json
"scripts": {
"dev": "nodemon app.js"
}
npm run dev
반응형
'개발정리 (nodeJS)' 카테고리의 다른 글
[nodeJS] Multer로 파일 업로드 구현하기 (0) | 2023.06.15 |
---|---|
[nodeJS] Moment로 날짜, 시간 포맷 바꾸기 (0) | 2023.06.14 |
[nodeJS] nodemailer로 메일 보내기 (0) | 2023.06.12 |
[nodeJS] 초보자도 쉽게 따라할 수 있는 nodeJS로 ejs 사용하는 방법 (0) | 2023.06.10 |
[nodeJS] Nodemon으로 서버유지하기 (2) | 2023.06.09 |