overleaf/services/chat/app/js/server.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const metrics = require('metrics-sharelatex')
metrics.initialize('chat')
2019-01-04 11:37:48 +00:00
const logger = require('logger-sharelatex')
2019-02-05 18:50:57 +00:00
logger.initialize('chat')
const Path = require('path')
const express = require('express')
const app = express()
const server = require('http').createServer(app)
const Router = require('./router')
2014-08-15 09:50:36 +00:00
app.use(express.bodyParser())
app.use(metrics.http.monitor(logger))
2019-01-04 11:37:48 +00:00
metrics.injectMetricsRoute(app)
2014-08-15 09:50:36 +00:00
if (app.get('env') === 'development') {
console.log('Development Enviroment')
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))
}
2014-08-15 09:50:36 +00:00
if (app.get('env') === 'production') {
console.log('Production Enviroment')
app.use(express.logger())
app.use(express.errorHandler())
}
2014-08-15 09:50:36 +00:00
const profiler = require('v8-profiler')
app.get('/profile', function(req, res) {
const time = parseInt(req.query.time || '1000')
profiler.startProfiling('test')
return setTimeout(function() {
const profile = profiler.stopProfiling('test')
return res.json(profile)
}, time)
})
2014-08-15 09:50:36 +00:00
Router.route(app)
2014-08-15 09:50:36 +00:00
module.exports = {
server,
app
}