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"
|
|
|
|
|
2015-11-19 11:00:12 -05:00
|
|
|
app.use express.bodyParser()
|
|
|
|
app.use metrics.http.monitor(logger)
|
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()
|
2017-01-18 08:34:28 -05:00
|
|
|
|
|
|
|
profiler = require "v8-profiler"
|
|
|
|
app.get "/profile", (req, res) ->
|
|
|
|
time = parseInt(req.query.time || "1000")
|
|
|
|
profiler.startProfiling("test")
|
|
|
|
setTimeout () ->
|
|
|
|
profile = profiler.stopProfiling("test")
|
|
|
|
res.json(profile)
|
|
|
|
, time
|
2014-08-15 05:50:36 -04:00
|
|
|
|
2017-01-18 08:34:28 -05:00
|
|
|
Router.route(app)
|
2014-08-15 05:50:36 -04:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
server: server
|
|
|
|
app: app
|
|
|
|
}
|
|
|
|
|
|
|
|
|