Download & Build
$ git clone https://github.com/joyent/node.git$ git branch my-v0.10.26-release origin/v0.10.26-release
$ git checkout my-v0.10.26-release
$ ./configure --prefix=/usr/local/node/nodejs-v0.10.26
$ make test
$ make doc
$ make install
$ export PATH=/usr/local/node/nodejs-v0.10.26/bin:$PATH
Intall Nodeclipse
npm http GET https://registry.npmjs.org/nodeclipse
npm http GET https://registry.npmjs.org/nodeclipse
npm http GET https://registry.npmjs.org/nodeclipse
npm ERR! network tunneling socket could not be established, cause=140431497983808:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:766:
npm ERR! network
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! System Linux 3.11.0-17-generic
npm ERR! command "/usr/local/node/nodejs-v0.10.26/bin/node" "/usr/local/node/nodejs-v0.10.26/bin/npm" "install" "-g" "nodeclipse"
npm ERR! cwd /home/horacio
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/horacio/npm-debug.log
npm ERR! not ok code 0
FIX: quitar variables de entorno de configuracion de proxy
$ unset http_proxy
$ unset https_proxy
$ npm install -g nodeclipse
(...)
nodeclipse@0.10.10 /usr/local/node/nodejs-v0.10.26/lib/node_modules/nodeclipse
├── shelljs@0.2.6
└── optimist@0.6.1 (wordwrap@0.0.2, minimist@0.0.8)
$ npm install -g express
(...)
express@3.4.8 /usr/local/node/nodejs-v0.10.26/lib/node_modules/express
├── methods@0.1.0
├── merge-descriptors@0.0.1
├── range-parser@0.0.4
├── cookie-signature@1.0.1
├── fresh@0.2.0
├── debug@0.7.4
├── buffer-crc32@0.2.1
├── cookie@0.1.0
├── mkdirp@0.3.5
├── commander@1.3.2 (keypress@0.1.0)
├── send@0.1.4 (mime@1.2.11)
└── connect@2.12.0 (uid2@0.0.3, pause@0.0.1, qs@0.6.6, bytes@0.2.1, raw-body@1.1.2, batch@0.5.0, negotiator@0.3.0, multiparty@2.2.0)
$ npm install -g coffee-script
(...)
nodeclipse@0.10.10 /usr/local/node/nodejs-v0.10.26/lib/node_modules/nodeclipse
├── shelljs@0.2.6
└── optimist@0.6.1 (wordwrap@0.0.2, minimist@0.0.8)
$ cd /usr/local/java
$ tar xzf /home/horacio/Desktop/jdk-7u51-linux-i586.tar.gz
$ tar xzf /home/horacio/Desktop/eclipse-standard-kepler-SR1-linux-gtk.tar.gz
$ tar xzf /home/horacio/Desktop/eclipse-standard-kepler-SR1-linux-gtk.tar.gz
# Instalar plugin desde: http://www.nodeclipse.org/updates/
# con instrucciones en la seccion
# ... "B) UPDATE SITE (RECOMMENDED WAY: BIGGER CHOICE)"
Install Socket.IO
$ npm install socket.io
(...)
socket.io@0.9.16 node_modules/socket.io
├── base64id@0.1.0
├── policyfile@0.0.4
├── redis@0.7.3
└── socket.io-client@0.9.16 (xmlhttprequest@1.4.2, uglify-js@1.2.5, active-x-obfuscator@0.0.1, ws@0.4.31)
Primer proyecto Express
Nombre: first-nodejs-express-project
Template engine: https://github.com/visionmedia/jade
Tutorial: http://expressjs.com/guide.html
Al crear proyecto desde Nodeclipse, en STDOUT aparecio:
create : /tmp/express-work/1393180273605/first-nodejs-express-project
create : /tmp/express-work/1393180273605/first-nodejs-express-project/package.json
create : /tmp/express-work/1393180273605/first-nodejs-express-project/app.js
create : /tmp/express-work/1393180273605/first-nodejs-express-project/public
create : /tmp/express-work/1393180273605/first-nodejs-express-project/public/javascripts
create : /tmp/express-work/1393180273605/first-nodejs-express-project/public/images
create : /tmp/express-work/1393180273605/first-nodejs-express-project/public/stylesheets
create : /tmp/express-work/1393180273605/first-nodejs-express-project/public/stylesheets/style.css
create : /tmp/express-work/1393180273605/first-nodejs-express-project/routes
create : /tmp/express-work/1393180273605/first-nodejs-express-project/routes/index.js
create : /tmp/express-work/1393180273605/first-nodejs-express-project/routes/user.js
create : /tmp/express-work/1393180273605/first-nodejs-express-project/views
create : /tmp/express-work/1393180273605/first-nodejs-express-project/views/layout.jade
create : /tmp/express-work/1393180273605/first-nodejs-express-project/views/index.jade
install dependencies:
$ cd /tmp/express-work/1393180273605/first-nodejs-express-project && npm install
run the app:
$ node app
Redis + SocketIO
Cliente sugerido: https://github.com/mranney/node_redisPreviamente (por las dudas) instale los siguientes paquetes:
- libhiredis0.10
- libhiredis-dev
$ npm install hiredis
(...)
hiredis@0.1.16 node_modules/hiredis
└── bindings@1.1.1
$ npm install redis
(...)
redis@0.10.1 node_modules/redis
Pub/Sub Redis + Node.Js
- https://github.com/mranney/node_redis#publish--subscribe
- https://stackoverflow.com/questions/10142246/how-to-design-redis-pub-sub-for-an-instant-messaging-system?rq=1
- https://stackoverflow.com/questions/14115893/nodejs-render-raw-html-with-express
- ejs
- https://github.com/visionmedia/ejs
- http://embeddedjs.com/
- https://stackoverflow.com/questions/4529586/render-basic-html-view-in-node-js-express
- https://stackoverflow.com/questions/8688488/how-does-node-js-render-views
Para enviar msg desde cli
$ redis-cli
redis 127.0.0.1:6379> PUBLISH /app/user/123/notifications hola
(integer) 1
Socket.IO: URL customizados en cliente/servidor
Compartir session con Django-Redis
1) Desde el navegador, solicitar nro. aleatorioSET cookie-5ebc3e41-709c-4dc7-857c-15233c96516a user=45 EX 10 NX
2) Con el nro. aleatorio recibido en navegador, crear SocketIO pasando nro. aleatorio
3) Desde NodeJS, obtener desde REDIS el ID de usuario asociado al nro. aleatorio, y subscribirse a URL que contenga dicho numero:
subscriber.subscribe("/app/user/45/notifications");
- Esta solución requiere que los datos estén encriptados (ya que el nro. aleatorio es la clave para que no se puedan leer mensajes de otros usuarios).
Proxy reverso en Node.JS
_
Problema de proxy de POSTs:
ReplyDeletehttps://github.com/nodejitsu/node-http-proxy/issues/180