ffffng/server/app.js

31 lines
729 B
JavaScript
Raw Normal View History

2014-05-12 20:08:19 +02:00
'use strict';
angular.module('ffffng').factory('app', function (fs) {
var express = require('express');
2014-06-06 14:57:20 +02:00
var bodyParser = require('body-parser');
var compress = require('compression');
2014-05-12 20:08:19 +02:00
var app = express();
2014-06-06 14:57:20 +02:00
app.use(bodyParser());
2014-05-12 20:08:19 +02:00
var clientDir = __dirname + '/../client';
2014-06-06 14:57:20 +02:00
app.use(compress());
2014-05-12 20:08:19 +02:00
app.use('/', express.static(clientDir + '/'));
app.get('/', function (req, res, next) {
fs.readFile(clientDir + '/index.html', 'utf8', function (err, body) {
if (err) {
return next(err);
}
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(body);
return next();
});
});
return app;
});