일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- mosquitto
- 1883
- DataGridView 직접 입력
- Replication
- DatePicker
- setInterval 중지
- AntDesign
- 데이터테이블 데이터 넣기
- setInterval 정지
- 공인IP
- datagridview 직접입력
- mySQL_Replication
- 서버동기화
- pm2 확인
- 맥 어드레스
- map이 undefined가 뜰 때
- invalid data
- listener 1883
- pm2 시작
- c# datagridview 데이터 넣기
- setInterval clear
- setInterval 외부 정지
- pm2 상태 확인
- html #select #option #multiple
- transfer
- pm2
- timepicker
- mosquitto.conf
- pm2 설치
- allow_anonymouse
- Today
- Total
목록Node (30)
개발 노트
모듈 프로그래밍에서 모듈이란 외부의 영향을 받지 않는 재사용 가능한 코드의 묶음입니다. require() require메서드를 통해 Node.js에서 다른 모듈을 불러오는데 사용합니다. 이 메서드를 사용하면 다른 파일이나 모듈에서 정의된 함수나 객체를 현재 파일에서 사용할 수 있게됩니다. 다음과 같이 파라미터로 추가 할 모듈의 파일 경로 값을 받습니다. require('파일 경로'); const myModule = require('./myModule.js'); 위의 코드는 'myModule.js'라는 파일에서 내보낸 모듈을 불러오는 것입니다. module.exports // myModule.js function myFunction() { console.log('Hello, World!'); } modul..
nodejs 서버 생성 후 axios cheerio 라이브러리 설치 npm install axios cheerio 본 게시물에서는 inflearn 사이트를 크롤링하는 것으로 한다 inflearn.js 파일생성 // 특정 url 입력시 페이지에 있는 html 코드를 모두 가져옴 const axios = require('axios'); // 가지고 온 html을 파싱 const cheerio = require('cheerio'); const getHTML = async(keyword) => { try { // encodeURI를 사용하지않으면 한글 입력시 오류발생 return await axios.get('https://www.inflearn.com/courses?s=' + encodeURI(keyword)..
프로젝트 폴더에서 package.json 파일 생성(다음 명령어는 세팅을 생략하는 명령어이다) npm init -y express 설치 npm install express app.js 파일 생성 const express = require('express'); const app = express(); const port = 3000; app.get('/', (req, res) => { res.send('Hello, World!'); }); app.listen(port, () => { console.log(server Start!. http://localhost:${port}); }) 서버실행 명령어 node app.js 접속 URL http://localhost:3000
DB가 연결되었는지 체크해주는 함수 const check = async () => { return await new Promise((resolve, reject) => { console.log(111); dbPool.getConnection((err, connection) => { console.log(222); if (connection === undefined) { console.log(333); // return false; // reject(false); reject(false); } else { console.log(444); // return connection; resolve(connection); } }) }) } 본 코드로 들어가기 전에 테스트용으로 만든 test함수 const test ..
DB connection pool let dbPool = null; async function createPool() { try { dbPool = mysql.createPool({ host: '127.0.0.1', user: 'root', password: 'ekdnsel', database: 'dawoon', waitForConnections: true, // 연결이 사용 가능할 때까지 대기 connectionLimit: 1, // 연결 풀의 최대 연결 수 queueLimit: 0, // 대기열에 들어갈 연결 요청의 최대 수 (0은 무제한) reconnect: { autoReconnect: true, // 연결이 끊어졌을 때 자동 재연결 설정 maxReconnects: 3, // 최대 재시도 횟수 및..
const pool = mysql.createPool({ host: 호스트명, user: 유저명, password: 패스워드, database: DB명, waitForConnections: true, // 연결이 사용 가능할 때까지 대기 connectionLimit: 10, // 연결 풀의 최대 연결 수 queueLimit: 0, // 대기열에 들어갈 연결 요청의 최대 수 (0은 무제한) reconnect: { // 연결이 끊어졌을 때 자동 재연결 설정 autoReconnect: true, // 최대 재시도 횟수 및 재시도 간격(ms) maxReconnects: 10, reconnectInterval: 2000, }, }); // 연결 풀에서 연결을 가져와 사용 pool.getConnection((err..