mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
lint & format app.js
This commit is contained in:
parent
e089cfc93c
commit
ed7d277f98
1 changed files with 12 additions and 9 deletions
|
@ -10,7 +10,6 @@ const Metrics = require('metrics-sharelatex')
|
||||||
Metrics.initialize('doc-updater')
|
Metrics.initialize('doc-updater')
|
||||||
|
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const http = require('http')
|
|
||||||
const Settings = require('settings-sharelatex')
|
const Settings = require('settings-sharelatex')
|
||||||
const logger = require('logger-sharelatex')
|
const logger = require('logger-sharelatex')
|
||||||
logger.initialize('document-updater')
|
logger.initialize('document-updater')
|
||||||
|
@ -33,7 +32,7 @@ const Path = require('path')
|
||||||
const bodyParser = require('body-parser')
|
const bodyParser = require('body-parser')
|
||||||
|
|
||||||
Metrics.mongodb.monitor(
|
Metrics.mongodb.monitor(
|
||||||
Path.resolve(__dirname + '/node_modules/mongojs/node_modules/mongodb'),
|
Path.resolve(__dirname, '/node_modules/mongojs/node_modules/mongodb'),
|
||||||
logger
|
logger
|
||||||
)
|
)
|
||||||
Metrics.event_loop.monitor(logger, 100)
|
Metrics.event_loop.monitor(logger, 100)
|
||||||
|
@ -45,16 +44,16 @@ Metrics.injectMetricsRoute(app)
|
||||||
|
|
||||||
DispatchManager.createAndStartDispatchers(Settings.dispatcherCount || 10)
|
DispatchManager.createAndStartDispatchers(Settings.dispatcherCount || 10)
|
||||||
|
|
||||||
app.param('project_id', function (req, res, next, project_id) {
|
app.param('project_id', function (req, res, next, projectId) {
|
||||||
if (project_id != null ? project_id.match(/^[0-9a-f]{24}$/) : undefined) {
|
if (projectId != null ? projectId.match(/^[0-9a-f]{24}$/) : undefined) {
|
||||||
return next()
|
return next()
|
||||||
} else {
|
} else {
|
||||||
return next(new Error('invalid project id'))
|
return next(new Error('invalid project id'))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.param('doc_id', function (req, res, next, doc_id) {
|
app.param('doc_id', function (req, res, next, docId) {
|
||||||
if (doc_id != null ? doc_id.match(/^[0-9a-f]{24}$/) : undefined) {
|
if (docId != null ? docId.match(/^[0-9a-f]{24}$/) : undefined) {
|
||||||
return next()
|
return next()
|
||||||
} else {
|
} else {
|
||||||
return next(new Error('invalid doc id'))
|
return next(new Error('invalid doc id'))
|
||||||
|
@ -100,9 +99,12 @@ app.delete(
|
||||||
app.get('/flush_all_projects', HttpController.flushAllProjects)
|
app.get('/flush_all_projects', HttpController.flushAllProjects)
|
||||||
app.get('/flush_queued_projects', HttpController.flushQueuedProjects)
|
app.get('/flush_queued_projects', HttpController.flushQueuedProjects)
|
||||||
|
|
||||||
app.get('/total', function (req, res) {
|
app.get('/total', function (req, res, next) {
|
||||||
const timer = new Metrics.Timer('http.allDocList')
|
const timer = new Metrics.Timer('http.allDocList')
|
||||||
return RedisManager.getCountOfDocsInMemory(function (err, count) {
|
return RedisManager.getCountOfDocsInMemory(function (err, count) {
|
||||||
|
if (err) {
|
||||||
|
return next(err)
|
||||||
|
}
|
||||||
timer.done()
|
timer.done()
|
||||||
return res.send({ total: count })
|
return res.send({ total: count })
|
||||||
})
|
})
|
||||||
|
@ -203,8 +205,9 @@ const shutdownCleanly = (signal) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
const watchForEvent = (eventName) =>
|
const watchForEvent = (eventName) =>
|
||||||
docUpdaterRedisClient.on(eventName, (e) =>
|
docUpdaterRedisClient.on(
|
||||||
console.log(`redis event: ${eventName} ${e}`)
|
eventName,
|
||||||
|
(e) => console.log(`redis event: ${eventName} ${e}`) // eslint-disable-line no-console
|
||||||
)
|
)
|
||||||
|
|
||||||
const events = ['connect', 'ready', 'error', 'close', 'reconnecting', 'end']
|
const events = ['connect', 'ready', 'error', 'close', 'reconnecting', 'end']
|
||||||
|
|
Loading…
Reference in a new issue