Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing more examples

  • Loading branch information...
commit 66a621421667a7dfe7e54e23294db6b772ab843e 1 parent 6cae1f0
@tj tj authored
View
6 examples/form/app.js
@@ -1,10 +1,12 @@
+// Expose modules in ./support for demo purposes
+require.paths.unshift(__dirname + '/../../support');
+
/**
* Module dependencies.
*/
-var express = require('./../../lib/express'),
- sys = require('sys');
+var express = require('../../lib/express');
var app = express.createServer();
View
6 examples/format/app.js
@@ -1,4 +1,7 @@
+// Expose modules in ./support for demo purposes
+require.paths.unshift(__dirname + '/../../support');
+
/**
* Module dependencies.
*/
@@ -18,7 +21,8 @@ var items = [
// Routes
app.get('/', function(req, res, next){
- res.writeHead(200, { 'Content-Type': 'text/html' });
+ res.statusCode = 200;
+ res.setHeader('Content-Type', 'text/html');
res.write('<p>Visit /item/2</p>');
res.write('<p>Visit /item/2.json</p>');
res.write('<p>Visit /item/2.xml</p>');
View
10 examples/github/app.js
@@ -6,7 +6,7 @@ require.paths.unshift(__dirname + '/../../support');
* Module dependencies.
*/
-var express = require('./../../lib/express')
+var express = require('../../lib/express')
, http = require('http');
var app = express.createServer();
@@ -27,10 +27,10 @@ app.set('view engine', 'jade');
function request(path, fn){
var client = http.createClient(80, 'github.com')
, req = client.request('GET', '/api/v2/json' + path, { Host: 'github.com' });
- req.addListener('response', function(res){
+ req.on('response', function(res){
res.body = '';
- res.addListener('data', function(chunk){ res.body += chunk; });
- res.addListener('end', function(){
+ res.on('data', function(chunk){ res.body += chunk; });
+ res.on('end', function(){
try {
fn(null, JSON.parse(res.body));
} catch (err) {
@@ -109,7 +109,7 @@ app.get('/repos/*', function(req, res, next){
});
// Serve statics from ./public
-app.use(express.staticProvider(__dirname + '/public'));
+app.use(express.static(__dirname + '/public'));
// Listen on port 3000
app.listen(3000);
Please sign in to comment.
Something went wrong with that request. Please try again.