aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--app.js35
-rw-r--r--package.json12
-rw-r--r--public/stylesheets/style.css8
-rw-r--r--routes/index.js8
-rw-r--r--routes/user.js8
-rw-r--r--views/index.ejs11
6 files changed, 82 insertions, 0 deletions
diff --git a/app.js b/app.js
new file mode 100644
index 0000000..a781218
--- /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();
+
+app.configure(function(){
+ app.set('port', process.env.PORT || 3000);
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'ejs');
+ 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')));
+});
+
+app.configure('development', function(){
+ 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..fa8a6ed
--- /dev/null
+++ b/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "application-name",
+ "version": "0.0.1",
+ "private": true,
+ "scripts": {
+ "start": "node app"
+ },
+ "dependencies": {
+ "express": "3.1.0",
+ "ejs": "*"
+ }
+} \ 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.ejs b/views/index.ejs
new file mode 100644
index 0000000..1500071
--- /dev/null
+++ b/views/index.ejs
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title><%= title %></title>
+ <link rel='stylesheet' href='/stylesheets/style.css' />
+ </head>
+ <body>
+ <h1><%= title %></h1>
+ <p>Welcome to <%= title %></p>
+ </body>
+</html> \ No newline at end of file