EditorRouter.coffee 2.0 KB

123456789101112131415161718192021222324252627282930313233
  1. EditorHttpController = require('./EditorHttpController')
  2. AuthenticationController = require "../Authentication/AuthenticationController"
  3. AuthorizationMiddlewear = require('../Authorization/AuthorizationMiddlewear')
  4. RateLimiterMiddlewear = require('../Security/RateLimiterMiddlewear')
  5. module.exports =
  6. apply: (webRouter, apiRouter) ->
  7. webRouter.post '/project/:Project_id/doc', AuthorizationMiddlewear.ensureUserCanWriteProjectContent,
  8. RateLimiterMiddlewear.rateLimit({
  9. endpointName: "add-doc-to-project"
  10. params: ["Project_id"]
  11. maxRequests: 30
  12. timeInterval: 60
  13. }), EditorHttpController.addDoc
  14. webRouter.post '/project/:Project_id/folder', AuthorizationMiddlewear.ensureUserCanWriteProjectContent,
  15. RateLimiterMiddlewear.rateLimit({
  16. endpointName: "add-folder-to-project"
  17. params: ["Project_id"]
  18. maxRequests: 60
  19. timeInterval: 60
  20. }), EditorHttpController.addFolder
  21. webRouter.post '/project/:Project_id/:entity_type/:entity_id/rename', AuthorizationMiddlewear.ensureUserCanWriteProjectContent, EditorHttpController.renameEntity
  22. webRouter.post '/project/:Project_id/:entity_type/:entity_id/move', AuthorizationMiddlewear.ensureUserCanWriteProjectContent, EditorHttpController.moveEntity
  23. webRouter.delete '/project/:Project_id/file/:entity_id', AuthorizationMiddlewear.ensureUserCanWriteProjectContent, EditorHttpController.deleteFile
  24. webRouter.delete '/project/:Project_id/doc/:entity_id', AuthorizationMiddlewear.ensureUserCanWriteProjectContent, EditorHttpController.deleteDoc
  25. webRouter.delete '/project/:Project_id/folder/:entity_id', AuthorizationMiddlewear.ensureUserCanWriteProjectContent, EditorHttpController.deleteFolder
  26. # Called by the real-time API to load up the current project state.
  27. # This is a post request because it's more than just a getting of data. We take actions
  28. # whenever a user joins a project, like updating the deleted status.
  29. apiRouter.post '/project/:Project_id/join', AuthenticationController.httpAuth, EditorHttpController.joinProject