remove decaff headers, fix camelcase

This commit is contained in:
Brian Gough 2021-08-03 10:12:16 +01:00
parent 9a14d01517
commit 9c50a2488f

View file

@ -1,6 +1,3 @@
/* eslint-disable
camelcase,
*/
let DocstoreClient let DocstoreClient
const request = require('request').defaults({ jar: false }) const request = require('request').defaults({ jar: false })
const settings = require('@overleaf/settings') const settings = require('@overleaf/settings')
@ -22,10 +19,10 @@ async function getStringFromPersistor(persistor, bucket, key) {
} }
module.exports = DocstoreClient = { module.exports = DocstoreClient = {
createDoc(project_id, doc_id, lines, version, ranges, callback) { createDoc(projectId, docId, lines, version, ranges, callback) {
return DocstoreClient.updateDoc( return DocstoreClient.updateDoc(
project_id, projectId,
doc_id, docId,
lines, lines,
version, version,
ranges, ranges,
@ -33,10 +30,10 @@ module.exports = DocstoreClient = {
) )
}, },
getDoc(project_id, doc_id, qs, callback) { getDoc(projectId, docId, qs, callback) {
request.get( request.get(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`,
json: true, json: true,
qs, qs,
}, },
@ -44,10 +41,10 @@ module.exports = DocstoreClient = {
) )
}, },
peekDoc(project_id, doc_id, qs, callback) { peekDoc(projectId, docId, qs, callback) {
request.get( request.get(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}/peek`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/peek`,
json: true, json: true,
qs, qs,
}, },
@ -55,20 +52,20 @@ module.exports = DocstoreClient = {
) )
}, },
isDocDeleted(project_id, doc_id, callback) { isDocDeleted(projectId, docId, callback) {
request.get( request.get(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}/deleted`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/deleted`,
json: true, json: true,
}, },
callback callback
) )
}, },
getAllDocs(project_id, callback) { getAllDocs(projectId, callback) {
request.get( request.get(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc`,
json: true, json: true,
}, },
(req, res, body) => { (req, res, body) => {
@ -77,10 +74,10 @@ module.exports = DocstoreClient = {
) )
}, },
getAllDeletedDocs(project_id, callback) { getAllDeletedDocs(projectId, callback) {
request.get( request.get(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc-deleted`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc-deleted`,
json: true, json: true,
}, },
(error, res, body) => { (error, res, body) => {
@ -93,20 +90,20 @@ module.exports = DocstoreClient = {
) )
}, },
getAllRanges(project_id, callback) { getAllRanges(projectId, callback) {
request.get( request.get(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/ranges`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/ranges`,
json: true, json: true,
}, },
callback callback
) )
}, },
updateDoc(project_id, doc_id, lines, version, ranges, callback) { updateDoc(projectId, docId, lines, version, ranges, callback) {
return request.post( return request.post(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`,
json: { json: {
lines, lines,
version, version,
@ -117,78 +114,78 @@ module.exports = DocstoreClient = {
) )
}, },
deleteDoc(project_id, doc_id, callback) { deleteDoc(projectId, docId, callback) {
DocstoreClient.deleteDocWithDateAndName( DocstoreClient.deleteDocWithDateAndName(
project_id, projectId,
doc_id, docId,
new Date(), new Date(),
'main.tex', 'main.tex',
callback callback
) )
}, },
deleteDocWithDate(project_id, doc_id, date, callback) { deleteDocWithDate(projectId, docId, date, callback) {
DocstoreClient.deleteDocWithDateAndName( DocstoreClient.deleteDocWithDateAndName(
project_id, projectId,
doc_id, docId,
date, date,
'main.tex', 'main.tex',
callback callback
) )
}, },
deleteDocWithName(project_id, doc_id, name, callback) { deleteDocWithName(projectId, docId, name, callback) {
DocstoreClient.deleteDocWithDateAndName( DocstoreClient.deleteDocWithDateAndName(
project_id, projectId,
doc_id, docId,
new Date(), new Date(),
name, name,
callback callback
) )
}, },
deleteDocWithDateAndName(project_id, doc_id, deletedAt, name, callback) { deleteDocWithDateAndName(projectId, docId, deletedAt, name, callback) {
request.patch( request.patch(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`,
json: { name, deleted: true, deletedAt }, json: { name, deleted: true, deletedAt },
}, },
callback callback
) )
}, },
archiveAllDoc(project_id, callback) { archiveAllDoc(projectId, callback) {
request.post( request.post(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/archive`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/archive`,
}, },
callback callback
) )
}, },
archiveDocById(project_id, doc_id, callback) { archiveDocById(projectId, docId, callback) {
request.post( request.post(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}/archive`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/archive`,
}, },
callback callback
) )
}, },
destroyAllDoc(project_id, callback) { destroyAllDoc(projectId, callback) {
request.post( request.post(
{ {
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/destroy`, url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/destroy`,
}, },
callback callback
) )
}, },
getS3Doc(project_id, doc_id, callback) { getS3Doc(projectId, docId, callback) {
getStringFromPersistor( getStringFromPersistor(
Persistor, Persistor,
settings.docstore.bucket, settings.docstore.bucket,
`${project_id}/${doc_id}` `${projectId}/${docId}`
) )
.then(data => { .then(data => {
callback(null, JSON.parse(data)) callback(null, JSON.parse(data))