2014-08-15 05:50:36 -04:00
|
|
|
logger = require 'logger-sharelatex'
|
|
|
|
logger.initialize("chat-sharelatex")
|
|
|
|
metrics = require("metrics-sharelatex")
|
|
|
|
metrics.initialize("chat")
|
|
|
|
Path = require("path")
|
|
|
|
express = require("express")
|
|
|
|
app = express()
|
|
|
|
server = require("http").createServer(app)
|
|
|
|
Router = require "./router"
|
|
|
|
|
|
|
|
metrics.mongodb.monitor(Path.resolve(__dirname + "/../../node_modules/mongojs/node_modules/mongodb"), logger)
|
|
|
|
|
2015-11-19 11:00:12 -05:00
|
|
|
app.use express.bodyParser()
|
|
|
|
app.use metrics.http.monitor(logger)
|
2016-12-14 12:38:14 -05:00
|
|
|
Router.route(app)
|
2014-08-15 05:50:36 -04:00
|
|
|
|
2015-11-19 11:00:12 -05:00
|
|
|
if (app.get 'env') == 'development'
|
2014-08-15 05:50:36 -04:00
|
|
|
console.log "Development Enviroment"
|
|
|
|
app.use express.errorHandler({ dumpExceptions: true, showStack: true })
|
|
|
|
|
2015-11-19 11:00:12 -05:00
|
|
|
if (app.get 'env') == 'production'
|
2014-08-15 05:50:36 -04:00
|
|
|
console.log "Production Enviroment"
|
|
|
|
app.use express.logger()
|
|
|
|
app.use express.errorHandler()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mountPoint = "/chat"
|
|
|
|
app.use (req, res, next) ->
|
|
|
|
|
|
|
|
if req.url.slice(0, mountPoint.length) == mountPoint
|
|
|
|
req.url = req.url.slice(mountPoint.length)
|
|
|
|
next()
|
|
|
|
else
|
|
|
|
res.send(404)
|
|
|
|
|
|
|
|
app.use(express.static(__dirname + "/../../public/build"))
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
server: server
|
|
|
|
app: app
|
|
|
|
}
|
|
|
|
|
|
|
|
|