diff --git a/services/filestore/Makefile b/services/filestore/Makefile index a19cf67af4..8fa89b5692 100644 --- a/services/filestore/Makefile +++ b/services/filestore/Makefile @@ -50,6 +50,12 @@ lint: lint_fix: $(RUN_LINTING) lint:fix +lint_styles: + $(RUN_LINTING) lint:styles + +lint_styles_fix: + $(RUN_LINTING) lint:styles:fix + typecheck: $(RUN_LINTING) types:check diff --git a/services/filestore/app.js b/services/filestore/app.js index 149417d366..74b5fff246 100644 --- a/services/filestore/app.js +++ b/services/filestore/app.js @@ -86,6 +86,12 @@ app.delete( fileController.deleteProject ) +app.get( + '/project/:project_id/size', + keyBuilder.userProjectKeyMiddleware, + fileController.directorySize +) + app.head( '/template/:template_id/v/:version/:format', keyBuilder.templateFileKeyMiddleware, @@ -107,39 +113,6 @@ app.post( fileController.insertFile ) -app.head( - '/project/:project_id/public/:public_file_id', - keyBuilder.publicFileKeyMiddleware, - fileController.getFileHead -) -app.get( - '/project/:project_id/public/:public_file_id', - keyBuilder.publicFileKeyMiddleware, - fileController.getFile -) -app.post( - '/project/:project_id/public/:public_file_id', - keyBuilder.publicFileKeyMiddleware, - fileController.insertFile -) -app.put( - '/project/:project_id/public/:public_file_id', - keyBuilder.publicFileKeyMiddleware, - bodyParser.json(), - fileController.copyFile -) -app.delete( - '/project/:project_id/public/:public_file_id', - keyBuilder.publicFileKeyMiddleware, - fileController.deleteFile -) - -app.get( - '/project/:project_id/size', - keyBuilder.publicProjectKeyMiddleware, - fileController.directorySize -) - app.get( '/bucket/:bucket/key/*', keyBuilder.bucketFileKeyMiddleware, diff --git a/services/filestore/app/js/KeyBuilder.js b/services/filestore/app/js/KeyBuilder.js index fa6d969922..f67a0e81d7 100644 --- a/services/filestore/app/js/KeyBuilder.js +++ b/services/filestore/app/js/KeyBuilder.js @@ -5,8 +5,6 @@ module.exports = { addCachingToKey, userFileKeyMiddleware, userProjectKeyMiddleware, - publicFileKeyMiddleware, - publicProjectKeyMiddleware, bucketFileKeyMiddleware, templateFileKeyMiddleware, } @@ -40,23 +38,12 @@ function userFileKeyMiddleware(req, res, next) { function userProjectKeyMiddleware(req, res, next) { const { project_id: projectId } = req.params + req.project_id = projectId req.key = `${projectId}/` req.bucket = settings.filestore.stores.user_files next() } -function publicFileKeyMiddleware(req, res, next) { - if (settings.filestore.stores.public_files == null) { - return res.status(501).send('public files not available') - } - - const { project_id: projectId, public_file_id: publicFileId } = req.params - req.key = `${projectId}/${publicFileId}` - req.bucket = settings.filestore.stores.public_files - - next() -} - function bucketFileKeyMiddleware(req, res, next) { req.bucket = req.params.bucket req.key = req.params[0] @@ -82,12 +69,3 @@ function templateFileKeyMiddleware(req, res, next) { next() } - -function publicProjectKeyMiddleware(req, res, next) { - const { project_id: projectId } = req.params - - req.project_id = projectId - req.bucket = settings.filestore.stores.user_files - - next() -} diff --git a/services/filestore/buildscript.txt b/services/filestore/buildscript.txt index 694badea11..e9dda3ed60 100644 --- a/services/filestore/buildscript.txt +++ b/services/filestore/buildscript.txt @@ -2,7 +2,7 @@ filestore --data-dirs=uploads,user_files,template_files --dependencies=s3,gcs --docker-repos=gcr.io/overleaf-ops,us-east1-docker.pkg.dev/overleaf-ops/ol-docker ---env-add=ENABLE_CONVERSIONS="true",USE_PROM_METRICS="true",AWS_S3_USER_FILES_BUCKET_NAME=fake_user_files,AWS_S3_TEMPLATE_FILES_BUCKET_NAME=fake_template_files,AWS_S3_PUBLIC_FILES_BUCKET_NAME=fake_public_files,GCS_USER_FILES_BUCKET_NAME=fake_userfiles,GCS_TEMPLATE_FILES_BUCKET_NAME=fake_templatefiles,GCS_PUBLIC_FILES_BUCKET_NAME=fake_publicfiles +--env-add=ENABLE_CONVERSIONS="true",USE_PROM_METRICS="true",AWS_S3_USER_FILES_BUCKET_NAME=fake_user_files,AWS_S3_TEMPLATE_FILES_BUCKET_NAME=fake_template_files,GCS_USER_FILES_BUCKET_NAME=fake_userfiles,GCS_TEMPLATE_FILES_BUCKET_NAME=fake_templatefiles --env-pass-through= --esmock-loader=False --node-version=18.20.2 diff --git a/services/filestore/config/settings.defaults.js b/services/filestore/config/settings.defaults.js index 35c5b678b6..08fa66408f 100644 --- a/services/filestore/config/settings.defaults.js +++ b/services/filestore/config/settings.defaults.js @@ -17,8 +17,6 @@ if (process.env.BACKEND == null) { process.env.AWS_S3_USER_FILES_BUCKET_NAME process.env.TEMPLATE_FILES_BUCKET_NAME = process.env.AWS_S3_TEMPLATE_FILES_BUCKET_NAME - process.env.PUBLIC_FILES_BUCKET_NAME = - process.env.AWS_S3_PUBLIC_FILES_BUCKET_NAME } else { process.env.BACKEND = 'fs' process.env.USER_FILES_BUCKET_NAME = Path.join(__dirname, '../user_files') @@ -26,10 +24,6 @@ if (process.env.BACKEND == null) { __dirname, '../template_files' ) - process.env.PUBLIC_FILES_BUCKET_NAME = Path.join( - __dirname, - '../public_files' - ) } } @@ -79,7 +73,6 @@ const settings = { stores: { user_files: process.env.USER_FILES_BUCKET_NAME, template_files: process.env.TEMPLATE_FILES_BUCKET_NAME, - public_files: process.env.PUBLIC_FILES_BUCKET_NAME, }, fallback: process.env.FALLBACK_BACKEND diff --git a/services/filestore/docker-compose.ci.yml b/services/filestore/docker-compose.ci.yml index 01d13e08c5..aaa11bea6b 100644 --- a/services/filestore/docker-compose.ci.yml +++ b/services/filestore/docker-compose.ci.yml @@ -35,10 +35,8 @@ services: USE_PROM_METRICS: "true" AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files - AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files GCS_USER_FILES_BUCKET_NAME: fake_userfiles GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles - GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles depends_on: s3: condition: service_healthy @@ -58,7 +56,7 @@ services: s3: image: adobe/s3mock:2.4.14 environment: - - initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket + - initialBuckets=fake_user_files,fake_template_files,bucket healthcheck: test: wget --quiet --output-document=/dev/null http://localhost:9090 interval: 1s diff --git a/services/filestore/docker-compose.yml b/services/filestore/docker-compose.yml index c7a671d711..427384e452 100644 --- a/services/filestore/docker-compose.yml +++ b/services/filestore/docker-compose.yml @@ -51,10 +51,8 @@ services: USE_PROM_METRICS: "true" AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files - AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files GCS_USER_FILES_BUCKET_NAME: fake_userfiles GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles - GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles user: node depends_on: s3: @@ -66,7 +64,7 @@ services: s3: image: adobe/s3mock:2.4.14 environment: - - initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket + - initialBuckets=fake_user_files,fake_template_files,bucket healthcheck: test: wget --quiet --output-document=/dev/null http://localhost:9090 interval: 1s diff --git a/services/filestore/test/acceptance/js/FilestoreTests.js b/services/filestore/test/acceptance/js/FilestoreTests.js index edf71cfebf..441a179c59 100644 --- a/services/filestore/test/acceptance/js/FilestoreTests.js +++ b/services/filestore/test/acceptance/js/FilestoreTests.js @@ -88,10 +88,8 @@ describe('Filestore', function () { const BUCKET_NAMES = [ process.env.GCS_USER_FILES_BUCKET_NAME, - process.env.GCS_PUBLIC_FILES_BUCKET_NAME, process.env.GCS_TEMPLATE_FILES_BUCKET_NAME, `${process.env.GCS_USER_FILES_BUCKET_NAME}-deleted`, - `${process.env.GCS_PUBLIC_FILES_BUCKET_NAME}-deleted`, `${process.env.GCS_TEMPLATE_FILES_BUCKET_NAME}-deleted`, ] diff --git a/services/filestore/test/acceptance/js/TestConfig.js b/services/filestore/test/acceptance/js/TestConfig.js index 9cb1948722..4b72bc971d 100644 --- a/services/filestore/test/acceptance/js/TestConfig.js +++ b/services/filestore/test/acceptance/js/TestConfig.js @@ -24,7 +24,6 @@ function s3Stores() { return { user_files: process.env.AWS_S3_USER_FILES_BUCKET_NAME, template_files: process.env.AWS_S3_TEMPLATE_FILES_BUCKET_NAME, - public_files: process.env.AWS_S3_PUBLIC_FILES_BUCKET_NAME, } } @@ -44,14 +43,12 @@ function gcsStores() { return { user_files: process.env.GCS_USER_FILES_BUCKET_NAME, template_files: process.env.GCS_TEMPLATE_FILES_BUCKET_NAME, - public_files: process.env.GCS_PUBLIC_FILES_BUCKET_NAME, } } function fsStores() { return { user_files: Path.resolve(__dirname, '../../../user_files'), - public_files: Path.resolve(__dirname, '../../../public_files'), template_files: Path.resolve(__dirname, '../../../template_files'), } } @@ -59,7 +56,6 @@ function fsStores() { function fallbackStores(primaryConfig, fallbackConfig) { return { [primaryConfig.user_files]: fallbackConfig.user_files, - [primaryConfig.public_files]: fallbackConfig.public_files, [primaryConfig.template_files]: fallbackConfig.template_files, } }