add null checks and new body parser

This commit is contained in:
Henry Oswald 2018-05-21 10:11:47 +01:00
parent ac990f2aba
commit 3cf2e1d7c3
3 changed files with 6 additions and 4 deletions

View file

@ -1,4 +1,5 @@
express = require('express')
bodyParser = require "body-parser"
logger = require('logger-sharelatex')
logger.initialize("filestore")
settings = require("settings-sharelatex")
@ -61,7 +62,7 @@ app.use (req, res, next) ->
app.get "/project/:project_id/file/:file_id", keyBuilder.userFileKey, fileController.getFile
app.post "/project/:project_id/file/:file_id", keyBuilder.userFileKey, fileController.insertFile
app.put "/project/:project_id/file/:file_id", keyBuilder.userFileKey, express.bodyParser(), fileController.copyFile
app.put "/project/:project_id/file/:file_id", keyBuilder.userFileKey, bodyParser.json(), fileController.copyFile
app.del "/project/:project_id/file/:file_id", keyBuilder.userFileKey, fileController.deleteFile
app.get "/template/:template_id/v/:version/:format", keyBuilder.templateFileKey, fileController.getFile
@ -72,7 +73,7 @@ app.post "/template/:template_id/v/:version/:format", keyBuilder.templateFileKey
app.get "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey, fileController.getFile
app.post "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey, fileController.insertFile
app.put "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey, express.bodyParser(), fileController.copyFile
app.put "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey, bodyParser.json(), fileController.copyFile
app.del "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey, fileController.deleteFile
app.get "/project/:project_id/size", keyBuilder.publicProjectKey, fileController.directorySize

View file

@ -2,7 +2,7 @@ settings = require("settings-sharelatex")
logger = require("logger-sharelatex")
# assume s3 if none specified
settings.filestore.backend ||= "s3"
settings?.filestore?.backend ||= "s3"
logger.log backend:settings.filestore.backend, "Loading backend"

View file

@ -41,7 +41,8 @@
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0",
"stream-buffers": "~0.2.5",
"underscore": "~1.5.2",
"mocha": "^4.0.1"
"mocha": "^4.0.1",
"body-parser": "^1.2.0"
},
"devDependencies": {
"sinon": "",