(function() {
  var Hook, Server, express, path;
  var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };

  Hook = require("hook.io").Hook;

  express = require("express");

  path = require("path");

  exports.Server = Server = (function() {

    __extends(Server, Hook);

    function Server(options) {
      var _this = this;
      Server.__super__.constructor.call(this, options);
      this.on("hook::ready", function() {
        var app, sessionStore;
        app = module.exports = express.createServer();
        sessionStore = new express.session.MemoryStore();
        app.configure(function() {
          app.set("views", __dirname + "/../views");
          app.set("view engine", "coffee");
          app.set("view options", {
            layout: false
          });
          app.register(".coffee", require("coffeekup").adapters.express);
          app.use(express.bodyParser());
          app.use(express.methodOverride());
          app.use(express.cookieParser());
          app.use(express.session({
            store: sessionStore,
            secret: "secret",
            key: "express.sid"
          }));
          app.use(app.router);
          app.use("/", express.static(__dirname + "/../public"));
          app.use("/", express.static(__dirname + "/../docs"));
          return app.use("/vendor", express.static(__dirname + "/../vendor"));
        });
        app.configure("development", function() {
          return app.use(express.errorHandler({
            dumpExceptions: true,
            showStack: true
          }));
        });
        app.configure("production", function() {
          return app.use(express.errorHandler());
        });
        app.get("/doc", function(req, res, next) {
          return res.sendfile(path.normalize(__dirname + "/../docs/Statemachine.spec.html"));
        });
        app.get("/", function(req, res, next) {
          return res.render("index", {
            title: config.title,
            scripts: ["vendor/stativus/stativus", "app"],
            stylesheets: []
          });
        });
        app.listen(process.env.C9_PORT || 80);
        return console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
      });
    }

    return Server;

  })();

}).call(this);
