mystix
8/20/2010 - 6:22 AM

NodeJS scripts

NodeJS scripts

// NodeJS - Hello World! example
var http = require('http');

http.createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello Node.js\n');

    console.log(req.url);
    console.log(req.headers['user-agent']);
}).listen(8124, '127.0.0.1');

console.log('Server running at http://127.0.0.1:8124/');
#!/bin/bash

# Installs NodeJS, npm, ExpressJS + required depencies & other useful stuff via Homebrew

brew install node npm 
npm install express jade sass less

# install db bindings
npm install postgres mongodb

# install node-inspector
npm install node-inspector
// ExpressJS - Hello World! example
var express = require('express'),
    app = express.createServer();

app.get('/', function(req, res) {
    res.redirect('/hello/world');
});

app.get('/hello/world', function(req, res) {
    res.send('Hello World');
});

app.listen(3030);

console.log('expressjs app listening on localhost:3030');