MockTrackChangesApi.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Fix any style issues and re-enable lint.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS102: Remove unnecessary code created because of implicit returns
  6. * DS207: Consider shorter variations of null checks
  7. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  8. */
  9. let MockTrackChangesApi
  10. const express = require('express')
  11. const app = express()
  12. module.exports = MockTrackChangesApi = {
  13. flushDoc(docId, callback) {
  14. if (callback == null) {
  15. callback = function () {}
  16. }
  17. return callback()
  18. },
  19. run() {
  20. app.post('/project/:project_id/doc/:doc_id/flush', (req, res, next) => {
  21. return this.flushDoc(req.params.doc_id, error => {
  22. if (error != null) {
  23. return res.sendStatus(500)
  24. } else {
  25. return res.sendStatus(204)
  26. }
  27. })
  28. })
  29. return app
  30. .listen(3015, error => {
  31. if (error != null) {
  32. throw error
  33. }
  34. })
  35. .on('error', error => {
  36. console.error('error starting MockTrackChangesApi:', error.message)
  37. return process.exit(1)
  38. })
  39. },
  40. }
  41. MockTrackChangesApi.run()