개발자의 노트
[Node.js] Node 6 설치 (CentOS)
소프트웨어개발/Node.js 2017. 10. 31. 15:34

git 설치 RHEL/CentOS 6 에는 git 1.7 이 포함되어 있는데. 이 버전이 https를 처리 못하는 버그가 있다고 한다. 따라서 git 버전을 확인해서 1.7이거나 아예 명령어를 인식하지 못한다면.. git 1.9 로 다시 설치하도록 하자. # git version git version 1.7.1 # git version -bash: git: command not found git 1.9 설치하기 # yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel cpio perl perl-ExtUtils-MakeMaker # cd /util/src # wget https://www.kernel.org/pub/soft..

[Node.js] forever 로그 남기지 않기
소프트웨어개발/Node.js 2017. 10. 25. 15:51

forever 모듈을 통해 node를 구동하면 forever 로그가 /root/.forever/ 폴더에 기본적으로 남는다.이 로그가 시간이 지날수록 점차 늘어나게 되어 디스크에 부담을 주게 되는데.logrotate 같은 것으로 관리를 해도 되겠지만, 애시당초 로그를 남기지 않게 하는 방법을 선호할 수도 있다.어차리 winstom 같은 로그 모듈로 특정 폴더에 로그를 남기게 할 경우 forever 로그가 딱히 필요가 없을 수 있기 때문이다. forever 구동시 아래와 같이 한다면,forever start app.js 로그를 남기지 않기 위해 -a -l /dev/null 을 옵션으로 추가해준다. forever start -a -l /dev/null app.js

[Node.js] Node용 Oracle모듈 설치 (strong-oracle)
소프트웨어개발/Node.js 2015. 4. 24. 19:16

node용 oracle을 설치하자. (strong-oracle 사용) 우선 오라클 instant client를 설치하자. (RPM 설치) 아래 사이트로 가서 RPM을 다운받는다. (64bit 기준) http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html 아래 두개의 파일을 다운받고 oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm RPM 설치를 한다. # rpm -ivh oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm # rpm -ivh ora..

[Node.js] 안드로이드 앱 버전 체크
소프트웨어개발/Node.js 2014. 12. 16. 14:17

웹 스크롤링 및 파싱을 위한 모듈에는 jsdom이나 cheerio 등이 있다. jsdom은 강력하긴 한데.. 워낙에 무겁고.. cpu가 100%을 달리는 경우가 발생하기도 하는 관계로간단히 구현하기에는 cheerio가 좋아보인다. https://github.com/cheeriojs/cheerio 예를 들어 https://play.google.com/store/apps/details?id=com.xxx.xxx.ver2 라는 앱이 있다고 하자.이에 해당하는 안드로이드 앱의 버전을 체크하는 구현 소스는 아래와 같다. var request = require('request'), cheerio = require('cheerio'); ... request({uri: 'https://play.google.com/st..

[Node.js] express.bodyParser()
소프트웨어개발/Node.js 2014. 2. 28. 11:59

http://expressjs.com/api.html#bodyParser express api 문서를 보면 app.use(express.bodyParser()); // is equivalent to: app.use(express.json()); app.use(express.urlencoded()); app.use(express.multipart()); 즉, express.bodyParser()는 express.json() / express.urlencoded() / express.multipart() 를 함께 선언한것과 동일하다. 따라서 파일업로드를 위한 기능을 제한하는 (사용하지 않는 경우) bodyParser()를 선언하기 보다는 json() 과 urlencoded() 만 별도로 선언하는 것이 좋겠다..

[Node.js] Socket.io에 세션을 이용하기 (session.socket.io)
소프트웨어개발/Node.js 2014. 2. 27. 18:17

socket.io에 세션을 처리하기 위해서 session.socket.io 모듈을 사용하면 된다. 서버 로직은 간단히 아래와 같은 형식이다. 클라이언트(javascript)는 socket.io를 사용할때와 동일하다. var SessionSockets = require('session.socket.io'), sessionSockets = new SessionSockets(io, sessionStore, cookieParser,'key'); sessionSockets.on('connection', function (err, socket, session) { logger.info('socket is connection: ' + session.id + ' - ', session); if(err) { logger..

[Node.js] Node에서 메일 발송하기 좋은 모듈 nodemailer (Amazon SES 지원)
소프트웨어개발/Node.js 2014. 2. 24. 13:58

http://www.nodemailer.com/ 아래와 같이 일반 SMTP 뿐 아니라 아마존 SES 서비스를 통한 메일 발송도 아주 간단하게 처리 가능하다. (본인도 아마존 SES 사용 중) SMTP for using SMTPSES for using Amazon SESSendmail for utilizing systems sendmail commandPickup for storing the e-mail in a directory on your machineDirect for sending e-mails directly to recipients MTA servers 사용법도 매우 간단하니 아래 예제를 참고하면 된다. http://www.nodemailer.com/docs/usage-example 라이선스는..

[Node.js] Same Origin Policy (크로스 도메인) 간단 해결
소프트웨어개발/Node.js 2014. 2. 24. 13:45

XMLHttpRequest cannot load ...."URL" not allowed by Access-Control-Allow-Origin 와 같은 에러가 발생하는 이유는 Same Origin Policy 라고 해서 크로스 도메인 정책에 의해 발생한다. Node.js 의 cors 모듈을 사용하면 편하게 해결 가능하다 cors = require('cors'); 하고 나서 app.use(cors()); app.use(app.router); 만 해주면 끝. * 반드시 router 전에 선언해주도록 한다.