2014-11-06 06:53:59 -05:00
|
|
|
EditorHttpController = require('./EditorHttpController')
|
2015-04-15 06:14:38 -04:00
|
|
|
AuthenticationController = require "../Authentication/AuthenticationController"
|
2019-03-04 07:02:28 -05:00
|
|
|
AuthorizationMiddleware = require('../Authorization/AuthorizationMiddleware')
|
|
|
|
RateLimiterMiddleware = require('../Security/RateLimiterMiddleware')
|
2014-11-06 06:53:59 -05:00
|
|
|
|
|
|
|
module.exports =
|
2015-06-30 09:38:32 -04:00
|
|
|
apply: (webRouter, apiRouter) ->
|
2019-03-04 07:02:28 -05:00
|
|
|
webRouter.post '/project/:Project_id/doc', AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
2019-01-18 05:10:09 -05:00
|
|
|
endpointName: "add-doc-to-project"
|
|
|
|
params: ["Project_id"]
|
|
|
|
maxRequests: 30
|
|
|
|
timeInterval: 60
|
|
|
|
}), EditorHttpController.addDoc
|
2019-03-04 07:02:28 -05:00
|
|
|
webRouter.post '/project/:Project_id/folder', AuthorizationMiddleware.ensureUserCanWriteProjectContent,
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
2019-01-18 05:10:09 -05:00
|
|
|
endpointName: "add-folder-to-project"
|
|
|
|
params: ["Project_id"]
|
|
|
|
maxRequests: 60
|
|
|
|
timeInterval: 60
|
|
|
|
}), EditorHttpController.addFolder
|
2014-11-06 06:53:59 -05:00
|
|
|
|
2019-03-04 07:02:28 -05:00
|
|
|
webRouter.post '/project/:Project_id/:entity_type/:entity_id/rename', AuthorizationMiddleware.ensureUserCanWriteProjectContent, EditorHttpController.renameEntity
|
|
|
|
webRouter.post '/project/:Project_id/:entity_type/:entity_id/move', AuthorizationMiddleware.ensureUserCanWriteProjectContent, EditorHttpController.moveEntity
|
2014-11-06 06:53:59 -05:00
|
|
|
|
2019-03-04 07:02:28 -05:00
|
|
|
webRouter.delete '/project/:Project_id/file/:entity_id', AuthorizationMiddleware.ensureUserCanWriteProjectContent, EditorHttpController.deleteFile
|
|
|
|
webRouter.delete '/project/:Project_id/doc/:entity_id', AuthorizationMiddleware.ensureUserCanWriteProjectContent, EditorHttpController.deleteDoc
|
|
|
|
webRouter.delete '/project/:Project_id/folder/:entity_id', AuthorizationMiddleware.ensureUserCanWriteProjectContent, EditorHttpController.deleteFolder
|
2014-11-06 06:53:59 -05:00
|
|
|
|
2014-11-07 07:31:47 -05:00
|
|
|
# Called by the real-time API to load up the current project state.
|
|
|
|
# This is a post request because it's more than just a getting of data. We take actions
|
|
|
|
# whenever a user joins a project, like updating the deleted status.
|
2019-04-12 05:39:04 -04:00
|
|
|
apiRouter.post '/project/:Project_id/join', AuthenticationController.httpAuth,
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: "join-project"
|
|
|
|
params: ["Project_id"]
|
|
|
|
maxRequests: 30
|
|
|
|
timeInterval: 60
|
|
|
|
}), EditorHttpController.joinProject
|