Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
added static file server in /static via express
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrecny committed Mar 27, 2012
1 parent 2c3669a commit 0fc4eac
Show file tree
Hide file tree
Showing 4 changed files with 415 additions and 0 deletions.
41 changes: 41 additions & 0 deletions static/app.js
@@ -0,0 +1,41 @@

/**
* Module dependencies.
*/

var express = require('express')
, fs = require('fs');

var app = module.exports = express.createServer();

// Configuration

var static_dir = __dirname + '/../client-build';
var index = fs.readFileSync(__dirname+'/../client-build/index.html', 'utf8');
//var gametypes = fs.readFileSync(__dirname+'/../shared/js/gametypes.js', 'utf8');

app.configure(function(){
app.use(express.bodyParser());
app.use(express.methodOverride());
console.log('serving static from ', static_dir);
app.use(express.static(static_dir));
});

app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function(){
app.use(express.errorHandler());
});

// Routes

app.get('/', function(req, res){
res.end(index);
});
/*app.get('/shared/js/gametypes.js', function(req, res){
res.end(gametypes);
});*/
app.listen(8001);
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
8 changes: 8 additions & 0 deletions static/package.json
@@ -0,0 +1,8 @@
{
"name": "application-name"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"express": "2.5.8"
}
}
8 changes: 8 additions & 0 deletions static/routes/index.js
@@ -0,0 +1,8 @@

/*
* GET home page.
*/

exports.index = function(req, res){
res.render('index', { title: 'Express' })
};

0 comments on commit 0fc4eac

Please sign in to comment.