Permalink
Browse files

deprecate .createServer() & remove old stale examples

  • Loading branch information...
1 parent 2d91eac commit 42fd29efe8c11cfb3485a872295448225afc1e89 @tj tj committed Jul 24, 2012
View
@@ -9,10 +9,9 @@ var express = require('../../lib/express');
var pub = __dirname + '/public';
-// Auto-compile sass to css with "compiler"
-// and then serve with connect's staticProvider
+// setup middleware
-var app = express.createServer();
+var app = express();
app.use(app.router);
app.use(express.static(pub));
app.use(express.errorHandler());
View
@@ -1,32 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var express = require('../../lib/express');
-
-var app = express.createServer();
-
-// Optional since express defaults to CWD/views
-
-app.set('views', __dirname + '/views');
-
-// Set our default template engine to "jade"
-// which prevents the need for extensions
-// (although you can still mix and match)
-app.set('view engine', 'jade');
-
-// Dummy record
-var ninja = {
- name: 'leonardo',
- summary: { email: 'hunter.loftis+github@gmail.com', master: 'splinter', description: 'peaceful leader' },
- weapons: ['katana', 'fists', 'shell'],
- victims: ['shredder', 'brain', 'beebop', 'rocksteady']
-};
-
-app.get('/', function(req, res){
- res.render('ninja', { ninja: ninja });
-});
-
-app.listen(3000);
-console.log('Express app started on port 3000');
@@ -1,5 +0,0 @@
-!!!
-html
- head
- title Partials Example
- body!= body
@@ -1 +0,0 @@
-li= value
@@ -1 +0,0 @@
-li.weapon= weapon
@@ -1,22 +0,0 @@
-h1= ninja.name
-
-// file, partial name, and partial object all match ('summary')
-// the partial filename prefix '_' is completely optional.
-
-// In this case we need to specify ninja.summary as the object
-// option, since it is a "plain" object Express cannot otherwise
-// tell if it is intended to be locals, or THE summary object
-#summary!= partial('summary', { object: ninja.summary })
-
-// file, partial name = '_weapon', resolves to 'weapon' object within partial
-#weapons
- h2 Weapons
- // the weapon partial is rendered once per item in
- // the weapons array or "collection"
- ul!= partial('weapon', ninja.weapons)
-
-// partial name 'victim' resolves to 'victim.jade'
-// or 'victim/index.jade', providing the "victim" local
-#victims
- h2 Victims
- ul!= partial('victim', ninja.victims)
@@ -1,4 +0,0 @@
-h2 Summary
-p= summary.email
-p= summary.description
-p taught by master #{summary.master}
@@ -1,5 +0,0 @@
-// this is insane overkill, I do not recommend
-// doing tiny partials like this as it gets expensive
-// with collections, however this illustrates the new
-// partial lookup mechanism
-!= partial('../../li', { object: victim, as: 'value' })
@@ -4,7 +4,7 @@
var express = require('../../lib/express');
-var app = express.createServer();
+var app = express();
// Example requests:
// curl http://localhost:3000/user/0
@@ -3,8 +3,8 @@
* Module dependencies.
*/
-var express = require('../../lib/express')
- , app = express.createServer()
+var express = require('../..')
+ , app = express()
, site = require('./site')
, post = require('./post')
, user = require('./user');
View
@@ -1,44 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var express = require('../../')
- , path = require('path')
- , exec = require('child_process').exec
- , fs = require('fs');
-
-/**
- * Error handler.
- */
-
-function errorHandler(voice) {
- return function(err, req, res, next) {
- var parts = err.stack.split('\n')[1].split(/[()]/)[1].split(':')
- , filename = parts.shift()
- , basename = path.basename(filename)
- , lineno = parts.shift()
- , col = parts.shift()
- , lines = fs.readFileSync(filename, 'utf8').split('\n')
- , line = lines[lineno - 1].replace(/\./, ' ');
-
- exec('say -v "' + voice + '" '
- + err.message
- + ' on line ' + lineno
- + ' of ' + basename + '.'
- + ' The contents of this line is '
- + ' "' + line + '".');
-
- res.send(500);
- }
-}
-
-var app = express.createServer();
-
-app.get('/', function(request, response){
- if (request.is(foo)) response.end('bar');
-});
-
-app.use(errorHandler('Vicki'));
-
-app.listen(3000);
View
@@ -1,51 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var express = require('../../lib/express')
- , stylus = require('stylus');
-
-var app = express.createServer();
-
-// $ npm install stylus
-
-// completely optional, however
-// the compile function allows you to
-// define additional functions exposed to Stylus,
-// alter settings, etc
-
-function compile(str, path) {
- return stylus(str)
- .set('filename', path)
- .set('compress', true);
-};
-
-// add the stylus middleware, which re-compiles when
-// a stylesheet has changed, compiling FROM src,
-// TO dest. dest is optional, defaulting to src
-
-app.use(stylus.middleware({
- src: __dirname + '/views'
- , dest: __dirname + '/public'
- , compile: compile
-}));
-
-
-// minimal setup both reading and writting to ./public
-// would look like:
-// app.use(stylus.middleware({ src: __dirname + '/public' }));
-
-// the middleware itself does not serve the static
-// css files, so we need to expose them with staticProvider
-
-app.use(express.static(__dirname + '/public'));
-
-app.set('views', __dirname + '/views');
-
-app.get('/', function(req, res){
- res.render('index.jade');
-});
-
-app.listen(3000);
-console.log('server listening on port 3000');
@@ -1 +0,0 @@
-*.css
@@ -1,2 +0,0 @@
-h1 Stylus
-p Just an example of using Stylus with Express.
@@ -1,6 +0,0 @@
-html
- head
- title Stylus Example
- link(rel='stylesheet', href='/reset.css')
- link(rel='stylesheet', href='/main.css')
- body!= body
@@ -1,8 +0,0 @@
-
-body
- font 14px helvetica, arial, sans-serif
- padding 50px
- h1
- font-size 50px
- p
- margin 15px 0
View
@@ -60,10 +60,19 @@ for (var key in connect.middleware) {
}
/**
- * Backwards compat.
+ * Error on createServer().
*/
-exports.createServer = createApplication;
+exports.createServer = function(){
+ console.warn('Warning: express.createServer() is deprecated, express');
+ console.warn('applications no longer inherit from http.Server,');
+ console.warn('please use:');
+ console.warn('');
+ console.warn(' var express = require("express");');
+ console.warn(' var app = express();');
+ console.warn('');
+ return createApplication();
+};
/**
* Expose the prototypes.

0 comments on commit 42fd29e

Please sign in to comment.