diff --git a/app.js b/app.js new file mode 100644 index 0000000..2b402ef --- /dev/null +++ b/app.js @@ -0,0 +1,35 @@ + +/** + * Module dependencies. + */ + +var express = require('express') + , routes = require('./routes') + , user = require('./routes/user') + , http = require('http') + , path = require('path'); + +var app = express(); + +// all environments +app.set('port', process.env.PORT || 3000); +app.set('views', __dirname + '/views'); +app.set('view engine', 'jade'); +app.use(express.favicon()); +app.use(express.logger('dev')); +app.use(express.bodyParser()); +app.use(express.methodOverride()); +app.use(app.router); +app.use(express.static(path.join(__dirname, 'public'))); + +// development only +if ('development' == app.get('env')) { + app.use(express.errorHandler()); +} + +app.get('/', routes.index); +app.get('/users', user.list); + +http.createServer(app).listen(app.get('port'), function(){ + console.log('Express server listening on port ' + app.get('port')); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..ae9468b --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "application-name", + "version": "0.0.1", + "private": true, + "scripts": { + "start": "node app.js" + }, + "dependencies": { + "express": "3.3.4", + "jade": "*" + } +} \ No newline at end of file diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css new file mode 100644 index 0000000..30e047d --- /dev/null +++ b/public/stylesheets/style.css @@ -0,0 +1,8 @@ +body { + padding: 50px; + font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; +} + +a { + color: #00B7FF; +} \ No newline at end of file diff --git a/routes/index.js b/routes/index.js new file mode 100644 index 0000000..f296005 --- /dev/null +++ b/routes/index.js @@ -0,0 +1,8 @@ + +/* + * GET home page. + */ + +exports.index = function(req, res){ + res.render('index', { title: 'Express' }); +}; \ No newline at end of file diff --git a/routes/user.js b/routes/user.js new file mode 100644 index 0000000..d5b34aa --- /dev/null +++ b/routes/user.js @@ -0,0 +1,8 @@ + +/* + * GET users listing. + */ + +exports.list = function(req, res){ + res.send("respond with a resource"); +}; \ No newline at end of file diff --git a/views/index.jade b/views/index.jade new file mode 100644 index 0000000..ef7b09f --- /dev/null +++ b/views/index.jade @@ -0,0 +1,5 @@ +extends layout + +block content + h1= title + p Welcome to #{title} \ No newline at end of file diff --git a/views/layout.jade b/views/layout.jade new file mode 100644 index 0000000..1b7b305 --- /dev/null +++ b/views/layout.jade @@ -0,0 +1,7 @@ +doctype 5 +html + head + title= title + link(rel='stylesheet', href='/stylesheets/style.css') + body + block content \ No newline at end of file