mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
decaffeinate: convert individual files to js
This commit is contained in:
parent
2616cde05e
commit
06b93447d5
2 changed files with 59 additions and 40 deletions
|
@ -1,45 +1,60 @@
|
|||
Metrics = require "metrics-sharelatex"
|
||||
Metrics.initialize("contacts")
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const Metrics = require("metrics-sharelatex");
|
||||
Metrics.initialize("contacts");
|
||||
|
||||
Settings = require "settings-sharelatex"
|
||||
logger = require "logger-sharelatex"
|
||||
express = require "express"
|
||||
bodyParser = require "body-parser"
|
||||
Errors = require "./app/js/Errors"
|
||||
HttpController = require "./app/js/HttpController"
|
||||
const Settings = require("settings-sharelatex");
|
||||
const logger = require("logger-sharelatex");
|
||||
const express = require("express");
|
||||
const bodyParser = require("body-parser");
|
||||
const Errors = require("./app/js/Errors");
|
||||
const HttpController = require("./app/js/HttpController");
|
||||
|
||||
Path = require "path"
|
||||
const Path = require("path");
|
||||
|
||||
|
||||
logger.initialize("contacts")
|
||||
Metrics.event_loop?.monitor(logger)
|
||||
logger.initialize("contacts");
|
||||
if (Metrics.event_loop != null) {
|
||||
Metrics.event_loop.monitor(logger);
|
||||
}
|
||||
|
||||
app = express()
|
||||
const app = express();
|
||||
|
||||
app.use Metrics.http.monitor(logger)
|
||||
app.use(Metrics.http.monitor(logger));
|
||||
|
||||
Metrics.injectMetricsRoute(app)
|
||||
Metrics.injectMetricsRoute(app);
|
||||
|
||||
app.get '/user/:user_id/contacts', HttpController.getContacts
|
||||
app.post '/user/:user_id/contacts', bodyParser.json(limit: "2mb"), HttpController.addContact
|
||||
app.get('/user/:user_id/contacts', HttpController.getContacts);
|
||||
app.post('/user/:user_id/contacts', bodyParser.json({limit: "2mb"}), HttpController.addContact);
|
||||
|
||||
app.get '/status', (req, res)->
|
||||
res.send('contacts is alive')
|
||||
app.get('/status', (req, res) => res.send('contacts is alive'));
|
||||
|
||||
app.use (error, req, res, next) ->
|
||||
logger.error err: error, "request errored"
|
||||
if error instanceof Errors.NotFoundError
|
||||
res.send 404
|
||||
else
|
||||
res.send(500, "Oops, something went wrong")
|
||||
app.use(function(error, req, res, next) {
|
||||
logger.error({err: error}, "request errored");
|
||||
if (error instanceof Errors.NotFoundError) {
|
||||
return res.send(404);
|
||||
} else {
|
||||
return res.send(500, "Oops, something went wrong");
|
||||
}
|
||||
});
|
||||
|
||||
port = Settings.internal.contacts.port
|
||||
host = Settings.internal.contacts.host
|
||||
const {
|
||||
port
|
||||
} = Settings.internal.contacts;
|
||||
const {
|
||||
host
|
||||
} = Settings.internal.contacts;
|
||||
|
||||
|
||||
if !module.parent # Called directly
|
||||
app.listen port, host, (error) ->
|
||||
throw error if error?
|
||||
logger.info "contacts starting up, listening on #{host}:#{port}"
|
||||
if (!module.parent) { // Called directly
|
||||
app.listen(port, host, function(error) {
|
||||
if (error != null) { throw error; }
|
||||
return logger.info(`contacts starting up, listening on ${host}:${port}`);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = app
|
||||
module.exports = app;
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
http = require('http')
|
||||
http.globalAgent.maxSockets = 300
|
||||
const http = require('http');
|
||||
http.globalAgent.maxSockets = 300;
|
||||
|
||||
module.exports =
|
||||
internal:
|
||||
contacts:
|
||||
port: 3036
|
||||
host: process.env["LISTEN_ADDRESS"] or "localhost"
|
||||
module.exports = {
|
||||
internal: {
|
||||
contacts: {
|
||||
port: 3036,
|
||||
host: process.env["LISTEN_ADDRESS"] || "localhost"
|
||||
}
|
||||
},
|
||||
|
||||
mongo:
|
||||
url: process.env['MONGO_CONNECTION_STRING'] or "mongodb://#{process.env["MONGO_HOST"] or "localhost"}/sharelatex"
|
||||
mongo: {
|
||||
url: process.env['MONGO_CONNECTION_STRING'] || `mongodb://${process.env["MONGO_HOST"] || "localhost"}/sharelatex`
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue