mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 13:53:40 -05:00
decaffeinate: Run post-processing cleanups on AppendingUpdatesTests.coffee and 11 other files
This commit is contained in:
parent
11c39cde65
commit
8fdf89b87c
12 changed files with 113 additions and 40 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
/* eslint-disable
|
||||||
|
handle-callback-err,
|
||||||
|
no-unused-vars,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
@ -19,7 +25,7 @@ const TrackChangesClient = require("./helpers/TrackChangesClient");
|
||||||
const MockWebApi = require("./helpers/MockWebApi");
|
const MockWebApi = require("./helpers/MockWebApi");
|
||||||
|
|
||||||
describe("Appending doc ops to the history", function() {
|
describe("Appending doc ops to the history", function() {
|
||||||
before(done=> TrackChangesApp.ensureRunning(done));
|
before(function(done) { return TrackChangesApp.ensureRunning(done); });
|
||||||
|
|
||||||
describe("when the history does not exist yet", function() {
|
describe("when the history does not exist yet", function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
@ -69,7 +75,7 @@ describe("Appending doc ops to the history", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
return it("should clear the doc from the DocsWithHistoryOps set", function(done) {
|
return it("should clear the doc from the DocsWithHistoryOps set", function(done) {
|
||||||
rclient.sismember(`DocsWithHistoryOps:${this.project_id}`, this.doc_id, function(error, member) {
|
rclient.sismember(`DocsWithHistoryOps:${this.project_id}`, this.doc_id, (error, member) => {
|
||||||
member.should.equal(0);
|
member.should.equal(0);
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/* eslint-disable
|
||||||
|
camelcase,
|
||||||
|
handle-callback-err,
|
||||||
|
no-undef,
|
||||||
|
no-unused-vars,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
@ -64,7 +72,7 @@ describe("Archiving updates", function() {
|
||||||
sinon.spy(MockDocStoreApi, "getAllDoc");
|
sinon.spy(MockDocStoreApi, "getAllDoc");
|
||||||
|
|
||||||
this.updates = [];
|
this.updates = [];
|
||||||
for (let i = 0, end = 512+10, asc = 0 <= end; asc ? i <= end : i >= end; asc ? i++ : i--) {
|
for (let i = 0, end = 512+10, asc = end >= 0; asc ? i <= end : i >= end; asc ? i++ : i--) {
|
||||||
this.updates.push({
|
this.updates.push({
|
||||||
op: [{ i: "a", p: 0 }],
|
op: [{ i: "a", p: 0 }],
|
||||||
meta: { ts: this.now + ((i-2048) * this.hours), user_id: this.user_id },
|
meta: { ts: this.now + ((i-2048) * this.hours), user_id: this.user_id },
|
||||||
|
@ -79,7 +87,7 @@ describe("Archiving updates", function() {
|
||||||
TrackChangesApp.ensureRunning(() => {
|
TrackChangesApp.ensureRunning(() => {
|
||||||
return TrackChangesClient.pushRawUpdates(this.project_id, this.doc_id, this.updates, error => {
|
return TrackChangesClient.pushRawUpdates(this.project_id, this.doc_id, this.updates, error => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return TrackChangesClient.flushDoc(this.project_id, this.doc_id, function(error) {
|
return TrackChangesClient.flushDoc(this.project_id, this.doc_id, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -99,7 +107,7 @@ describe("Archiving updates", function() {
|
||||||
|
|
||||||
describe("archiving a doc's updates", function() {
|
describe("archiving a doc's updates", function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
TrackChangesClient.pushDocHistory(this.project_id, this.doc_id, function(error) {
|
TrackChangesClient.pushDocHistory(this.project_id, this.doc_id, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -107,7 +115,7 @@ describe("Archiving updates", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have one cached pack", function(done) {
|
it("should have one cached pack", function(done) {
|
||||||
return db.docHistory.count({ doc_id: ObjectId(this.doc_id), expiresAt:{$exists:true}}, function(error, count) {
|
return db.docHistory.count({ doc_id: ObjectId(this.doc_id), expiresAt:{$exists:true}}, (error, count) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
count.should.equal(1);
|
count.should.equal(1);
|
||||||
return done();
|
return done();
|
||||||
|
@ -120,7 +128,7 @@ describe("Archiving updates", function() {
|
||||||
expiresAt:{$exists:true}
|
expiresAt:{$exists:true}
|
||||||
}, (err, result) => {
|
}, (err, result) => {
|
||||||
if (typeof error !== 'undefined' && error !== null) { throw error; }
|
if (typeof error !== 'undefined' && error !== null) { throw error; }
|
||||||
return db.docHistory.count({ doc_id: ObjectId(this.doc_id)}, function(error, count) {
|
return db.docHistory.count({ doc_id: ObjectId(this.doc_id)}, (error, count) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
count.should.equal(1);
|
count.should.equal(1);
|
||||||
return done();
|
return done();
|
||||||
|
@ -129,7 +137,7 @@ describe("Archiving updates", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a docHistoryIndex entry marked as inS3", function(done) {
|
it("should have a docHistoryIndex entry marked as inS3", function(done) {
|
||||||
return db.docHistoryIndex.findOne({ _id: ObjectId(this.doc_id) }, function(error, index) {
|
return db.docHistoryIndex.findOne({ _id: ObjectId(this.doc_id) }, (error, index) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
index.packs[0].inS3.should.equal(true);
|
index.packs[0].inS3.should.equal(true);
|
||||||
return done();
|
return done();
|
||||||
|
@ -137,7 +145,7 @@ describe("Archiving updates", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a docHistoryIndex entry with the last version", function(done) {
|
it("should have a docHistoryIndex entry with the last version", function(done) {
|
||||||
return db.docHistoryIndex.findOne({ _id: ObjectId(this.doc_id) }, function(error, index) {
|
return db.docHistoryIndex.findOne({ _id: ObjectId(this.doc_id) }, (error, index) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
index.packs[0].v_end.should.equal(1024);
|
index.packs[0].v_end.should.equal(1024);
|
||||||
return done();
|
return done();
|
||||||
|
@ -159,7 +167,7 @@ describe("Archiving updates", function() {
|
||||||
|
|
||||||
return describe("unarchiving a doc's updates", function() {
|
return describe("unarchiving a doc's updates", function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
TrackChangesClient.pullDocHistory(this.project_id, this.doc_id, function(error) {
|
TrackChangesClient.pullDocHistory(this.project_id, this.doc_id, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -167,7 +175,7 @@ describe("Archiving updates", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
return it("should restore both packs", function(done) {
|
return it("should restore both packs", function(done) {
|
||||||
return db.docHistory.count({ doc_id: ObjectId(this.doc_id) }, function(error, count) {
|
return db.docHistory.count({ doc_id: ObjectId(this.doc_id) }, (error, count) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
count.should.equal(2);
|
count.should.equal(2);
|
||||||
return done();
|
return done();
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
/* eslint-disable
|
||||||
|
handle-callback-err,
|
||||||
|
no-unused-vars,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
@ -19,7 +25,7 @@ const TrackChangesClient = require("./helpers/TrackChangesClient");
|
||||||
const MockWebApi = require("./helpers/MockWebApi");
|
const MockWebApi = require("./helpers/MockWebApi");
|
||||||
|
|
||||||
describe("Flushing updates", function() {
|
describe("Flushing updates", function() {
|
||||||
before(done=> TrackChangesApp.ensureRunning(done));
|
before(function(done) { return TrackChangesApp.ensureRunning(done); });
|
||||||
|
|
||||||
describe("flushing a doc's updates", function() {
|
describe("flushing a doc's updates", function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
@ -34,7 +40,7 @@ describe("Flushing updates", function() {
|
||||||
v: 3
|
v: 3
|
||||||
}], error => {
|
}], error => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return TrackChangesClient.flushDoc(this.project_id, this.doc_id, function(error) {
|
return TrackChangesClient.flushDoc(this.project_id, this.doc_id, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -43,7 +49,7 @@ describe("Flushing updates", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
return it("should flush the op into mongo", function(done) {
|
return it("should flush the op into mongo", function(done) {
|
||||||
TrackChangesClient.getCompressedUpdates(this.doc_id, function(error, updates) {
|
TrackChangesClient.getCompressedUpdates(this.doc_id, (error, updates) => {
|
||||||
expect(updates[0].pack[0].op).to.deep.equal([{
|
expect(updates[0].pack[0].op).to.deep.equal([{
|
||||||
p: 3, i: "f"
|
p: 3, i: "f"
|
||||||
}]);
|
}]);
|
||||||
|
@ -78,7 +84,7 @@ describe("Flushing updates", function() {
|
||||||
v: 3
|
v: 3
|
||||||
}], error => {
|
}], error => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return TrackChangesClient.flushProject(this.project_id, function(error) {
|
return TrackChangesClient.flushProject(this.project_id, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -87,7 +93,7 @@ describe("Flushing updates", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not mark the updates for deletion", function(done) {
|
it("should not mark the updates for deletion", function(done) {
|
||||||
TrackChangesClient.getCompressedUpdates(this.doc_id, function(error, updates) {
|
TrackChangesClient.getCompressedUpdates(this.doc_id, (error, updates) => {
|
||||||
expect(updates[0].expiresAt).to.not.exist;
|
expect(updates[0].expiresAt).to.not.exist;
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -95,7 +101,7 @@ describe("Flushing updates", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
return it("should preserve history forever", function(done) {
|
return it("should preserve history forever", function(done) {
|
||||||
TrackChangesClient.getProjectMetaData(this.project_id, function(error, project) {
|
TrackChangesClient.getProjectMetaData(this.project_id, (error, project) => {
|
||||||
expect(project.preserveHistory).to.equal(true);
|
expect(project.preserveHistory).to.equal(true);
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -127,7 +133,7 @@ describe("Flushing updates", function() {
|
||||||
v: 3
|
v: 3
|
||||||
}], error => {
|
}], error => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return TrackChangesClient.flushProject(this.project_id, function(error) {
|
return TrackChangesClient.flushProject(this.project_id, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -136,7 +142,7 @@ describe("Flushing updates", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
return it("should mark the updates for deletion", function(done) {
|
return it("should mark the updates for deletion", function(done) {
|
||||||
TrackChangesClient.getCompressedUpdates(this.doc_id, function(error, updates) {
|
TrackChangesClient.getCompressedUpdates(this.doc_id, (error, updates) => {
|
||||||
expect(updates[0].expiresAt).to.exist;
|
expect(updates[0].expiresAt).to.exist;
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -170,7 +176,7 @@ describe("Flushing updates", function() {
|
||||||
v: 3
|
v: 3
|
||||||
}], error => {
|
}], error => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return TrackChangesClient.flushProject(this.project_id, function(error) {
|
return TrackChangesClient.flushProject(this.project_id, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -180,7 +186,7 @@ describe("Flushing updates", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
return it("should not mark the updates for deletion", function(done) {
|
return it("should not mark the updates for deletion", function(done) {
|
||||||
TrackChangesClient.getCompressedUpdates(this.doc_id, function(error, updates) {
|
TrackChangesClient.getCompressedUpdates(this.doc_id, (error, updates) => {
|
||||||
expect(updates[0].expiresAt).to.not.exist;
|
expect(updates[0].expiresAt).to.not.exist;
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/* eslint-disable
|
||||||
|
no-unused-vars,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
/* eslint-disable
|
||||||
|
chai-friendly/no-unused-expressions,
|
||||||
|
no-unused-vars,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
/* eslint-disable
|
||||||
|
handle-callback-err,
|
||||||
|
no-unused-vars,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
@ -31,7 +37,7 @@ describe("Locking document", function() {
|
||||||
LockManager.runWithLock("doc123", releaseB => {
|
LockManager.runWithLock("doc123", releaseB => {
|
||||||
return releaseA();
|
return releaseA();
|
||||||
} // try to release lock A to see if it wipes out lock B
|
} // try to release lock A to see if it wipes out lock B
|
||||||
, function(error) {})
|
, (error) => {})
|
||||||
|
|
||||||
// we never release lock B so nothing should happen here
|
// we never release lock B so nothing should happen here
|
||||||
, 1500);
|
, 1500);
|
||||||
|
@ -44,7 +50,7 @@ describe("Locking document", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
return it("the new lock should not be removed by the expired locker", function(done) {
|
return it("the new lock should not be removed by the expired locker", function(done) {
|
||||||
LockManager.checkLock("doc123", function(err, isFree) {
|
LockManager.checkLock("doc123", (err, isFree) => {
|
||||||
expect(isFree).to.equal(false);
|
expect(isFree).to.equal(false);
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/* eslint-disable
|
||||||
|
no-unused-vars,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
/* eslint-disable
|
||||||
|
camelcase,
|
||||||
|
handle-callback-err,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
@ -18,7 +24,7 @@ module.exports = (MockDocUpdaterApi = {
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
app.get("/project/:project_id/doc", (req, res, next) => {
|
app.get("/project/:project_id/doc", (req, res, next) => {
|
||||||
return this.getAllDoc(req.params.project_id, function(error, docs) {
|
return this.getAllDoc(req.params.project_id, (error, docs) => {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
res.send(500);
|
res.send(500);
|
||||||
}
|
}
|
||||||
|
@ -30,9 +36,9 @@ module.exports = (MockDocUpdaterApi = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return app.listen(3016, function(error) {
|
return app.listen(3016, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
}).on("error", function(error) {
|
}).on("error", (error) => {
|
||||||
console.error("error starting MockDocStoreApi:", error.message);
|
console.error("error starting MockDocStoreApi:", error.message);
|
||||||
return process.exit(1);
|
return process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
/* eslint-disable
|
||||||
|
camelcase,
|
||||||
|
handle-callback-err,
|
||||||
|
no-undef,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
@ -25,7 +32,7 @@ module.exports = (MockDocUpdaterApi = {
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
app.get("/project/:project_id/doc/:doc_id", (req, res, next) => {
|
app.get("/project/:project_id/doc/:doc_id", (req, res, next) => {
|
||||||
return this.getDoc(req.params.project_id, req.params.doc_id, function(error, doc) {
|
return this.getDoc(req.params.project_id, req.params.doc_id, (error, doc) => {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
res.send(500);
|
res.send(500);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +45,7 @@ module.exports = (MockDocUpdaterApi = {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/project/:project_id/doc/:doc_id", express.bodyParser(), (req, res, next) => {
|
app.post("/project/:project_id/doc/:doc_id", express.bodyParser(), (req, res, next) => {
|
||||||
return this.setDoc(req.params.project_id, req.params.doc_id, req.body.lines, req.body.user_id, req.body.undoing, function(errr, doc) {
|
return this.setDoc(req.params.project_id, req.params.doc_id, req.body.lines, req.body.user_id, req.body.undoing, (errr, doc) => {
|
||||||
if (typeof error !== 'undefined' && error !== null) {
|
if (typeof error !== 'undefined' && error !== null) {
|
||||||
return res.send(500);
|
return res.send(500);
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,9 +54,9 @@ module.exports = (MockDocUpdaterApi = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return app.listen(3003, function(error) {
|
return app.listen(3003, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
}).on("error", function(error) {
|
}).on("error", (error) => {
|
||||||
console.error("error starting MockDocUpdaterApi:", error.message);
|
console.error("error starting MockDocUpdaterApi:", error.message);
|
||||||
return process.exit(1);
|
return process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
/* eslint-disable
|
||||||
|
camelcase,
|
||||||
|
handle-callback-err,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
@ -25,7 +31,7 @@ module.exports = (MockWebApi = {
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
app.get("/user/:user_id/personal_info", (req, res, next) => {
|
app.get("/user/:user_id/personal_info", (req, res, next) => {
|
||||||
return this.getUserInfo(req.params.user_id, function(error, user) {
|
return this.getUserInfo(req.params.user_id, (error, user) => {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
res.send(500);
|
res.send(500);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +44,7 @@ module.exports = (MockWebApi = {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/project/:project_id/details", (req, res, next) => {
|
app.get("/project/:project_id/details", (req, res, next) => {
|
||||||
return this.getProjectDetails(req.params.project_id, function(error, project) {
|
return this.getProjectDetails(req.params.project_id, (error, project) => {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
res.send(500);
|
res.send(500);
|
||||||
}
|
}
|
||||||
|
@ -50,9 +56,9 @@ module.exports = (MockWebApi = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return app.listen(3000, function(error) {
|
return app.listen(3000, (error) => {
|
||||||
if (error != null) { throw error; }
|
if (error != null) { throw error; }
|
||||||
}).on("error", function(error) {
|
}).on("error", (error) => {
|
||||||
console.error("error starting MockWebApiServer:", error.message);
|
console.error("error starting MockWebApiServer:", error.message);
|
||||||
return process.exit(1);
|
return process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/* eslint-disable
|
||||||
|
handle-callback-err,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS101: Remove unnecessary use of Array.from
|
* DS101: Remove unnecessary use of Array.from
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
/* eslint-disable
|
||||||
|
camelcase,
|
||||||
|
handle-callback-err,
|
||||||
|
no-unused-vars,
|
||||||
|
*/
|
||||||
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS101: Remove unnecessary use of Array.from
|
* DS101: Remove unnecessary use of Array.from
|
||||||
|
@ -26,7 +33,7 @@ const S3_BUCKET = Settings.trackchanges.stores.doc_history;
|
||||||
module.exports = (TrackChangesClient = {
|
module.exports = (TrackChangesClient = {
|
||||||
flushAndGetCompressedUpdates(project_id, doc_id, callback) {
|
flushAndGetCompressedUpdates(project_id, doc_id, callback) {
|
||||||
if (callback == null) { callback = function(error, updates) {}; }
|
if (callback == null) { callback = function(error, updates) {}; }
|
||||||
return TrackChangesClient.flushDoc(project_id, doc_id, function(error) {
|
return TrackChangesClient.flushDoc(project_id, doc_id, (error) => {
|
||||||
if (error != null) { return callback(error); }
|
if (error != null) { return callback(error); }
|
||||||
return TrackChangesClient.getCompressedUpdates(doc_id, callback);
|
return TrackChangesClient.getCompressedUpdates(doc_id, callback);
|
||||||
});
|
});
|
||||||
|
@ -82,7 +89,7 @@ module.exports = (TrackChangesClient = {
|
||||||
|
|
||||||
pushRawUpdates(project_id, doc_id, updates, callback) {
|
pushRawUpdates(project_id, doc_id, updates, callback) {
|
||||||
if (callback == null) { callback = function(error) {}; }
|
if (callback == null) { callback = function(error) {}; }
|
||||||
return rclient.sadd(Keys.docsWithHistoryOps({project_id}), doc_id, function(error) {
|
return rclient.sadd(Keys.docsWithHistoryOps({project_id}), doc_id, (error) => {
|
||||||
if (error != null) { return callback(error); }
|
if (error != null) { return callback(error); }
|
||||||
return rclient.rpush(Keys.uncompressedHistoryOps({doc_id}), ...Array.from(((Array.from(updates).map((u) => JSON.stringify(u))))), callback);
|
return rclient.rpush(Keys.uncompressedHistoryOps({doc_id}), ...Array.from(((Array.from(updates).map((u) => JSON.stringify(u))))), callback);
|
||||||
});
|
});
|
||||||
|
@ -147,7 +154,7 @@ module.exports = (TrackChangesClient = {
|
||||||
return done();
|
return done();
|
||||||
}
|
}
|
||||||
|
|
||||||
return request.get(`${Settings.trackchanges.s3.endpoint}/`, function(err, res) {
|
return request.get(`${Settings.trackchanges.s3.endpoint}/`, (err, res) => {
|
||||||
if (res && (res.statusCode < 500)) {
|
if (res && (res.statusCode < 500)) {
|
||||||
return done();
|
return done();
|
||||||
}
|
}
|
||||||
|
@ -168,11 +175,11 @@ module.exports = (TrackChangesClient = {
|
||||||
Key: `${project_id}/changes-${doc_id}/pack-${pack_id}`
|
Key: `${project_id}/changes-${doc_id}/pack-${pack_id}`
|
||||||
};
|
};
|
||||||
|
|
||||||
return s3.getObject(params, function(error, data) {
|
return s3.getObject(params, (error, data) => {
|
||||||
if (error != null) { return callback(error); }
|
if (error != null) { return callback(error); }
|
||||||
const body = data.Body;
|
const body = data.Body;
|
||||||
if ((body == null)) { return callback(new Error("empty response from s3")); }
|
if ((body == null)) { return callback(new Error("empty response from s3")); }
|
||||||
return zlib.gunzip(body, function(err, result) {
|
return zlib.gunzip(body, (err, result) => {
|
||||||
if (err != null) { return callback(err); }
|
if (err != null) { return callback(err); }
|
||||||
return callback(null, JSON.parse(result.toString()));
|
return callback(null, JSON.parse(result.toString()));
|
||||||
});
|
});
|
||||||
|
@ -186,7 +193,7 @@ module.exports = (TrackChangesClient = {
|
||||||
Prefix: `${project_id}/changes-${doc_id}`
|
Prefix: `${project_id}/changes-${doc_id}`
|
||||||
};
|
};
|
||||||
|
|
||||||
return s3.listObjects(params, function(error, data) {
|
return s3.listObjects(params, (error, data) => {
|
||||||
if (error != null) { return callback(error); }
|
if (error != null) { return callback(error); }
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
|
Loading…
Reference in a new issue