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