var express = require("express");
var fs = require("fs");
var Router = require("../flume/router");

var Application = function(configPath) {

	this.path = fs.realpathSync(configPath + "/..");

	// initialization
	this.expressServer = express();

	this.router = require(this.path + "/config/routes");
	this.router.express(this.expressServer);

	this.logger = require("./logger");

	// public instance methods

	this.exit = function(error) {
		this.logger.error(error);

		// FIXME: 0 is probably not correct here.
		process.exit(0);
	};

	this.expandPath = function(path) {
		// FIXME: this appending is bad.
		// do something fancy with fs.
		return this.path + '/' + path;
	};

	this.server = function(port, callback) {
		this.expressServer.listen(port, function() {
			Fluid.application.logger.success("Fluid is running at http://localhost:" + port + "/ - yay!");
			callback && callback();
		}).on("error", function(error) {
			Fluid.application.exit("A server is already running on port " + port + "\n  Try again with a different port.");
		});
	};

	// finalize setup

	Fluid.application = this;

};

module.exports = Application;

@@ -96,49 +96,159 @@
 %22);%0A
-%0Avar Application = function(configPath) %7B
+var EventEmitter = require(%22events%22).EventEmitter;%0A%0Avar Application = function(configPath) %7B%0A%09%0A%09// Inherit from EventEmitter.%0A%09EventEmitter.call(this);
 %0A%0A%09t

Make Fluid.application an EventEmitter.