server.js 894 B

123456789101112131415161718192021222324252627
  1. import metrics from '@overleaf/metrics'
  2. import Settings from '@overleaf/settings'
  3. import logger from '@overleaf/logger'
  4. import express from 'express'
  5. import bodyParser from 'body-parser'
  6. import * as SpellingAPIController from './SpellingAPIController.js'
  7. import * as HealthCheckController from './HealthCheckController.js'
  8. logger.initialize('spelling')
  9. if (Settings.sentry?.dsn != null) {
  10. logger.initializeErrorReporting(Settings.sentry.dsn)
  11. }
  12. metrics.memory.monitor(logger)
  13. metrics.leaked_sockets.monitor(logger)
  14. metrics.open_sockets.monitor()
  15. export const app = express()
  16. metrics.injectMetricsRoute(app)
  17. app.use(bodyParser.json({ limit: '2mb' }))
  18. app.use(metrics.http.monitor(logger))
  19. app.post('/user/:user_id/check', SpellingAPIController.check)
  20. app.get('/status', (req, res) => res.send({ status: 'spelling api is up' }))
  21. app.get('/health_check', HealthCheckController.healthCheck)