add per-user routes and methods

This commit is contained in:
Brian Gough
2016-05-27 15:29:26 +01:00
parent 8c42a353e1
commit 226e6c87b1
5 changed files with 68 additions and 42 deletions

View File

@@ -42,8 +42,8 @@ app.param 'project_id', (req, res, next, project_id) ->
else
next new Error("invalid project id")
app.param 'user_id', (req, res, next, project_id) ->
if project_id?.match /^[a-zA-Z0-9_-]+$/
app.param 'user_id', (req, res, next, user_id) ->
if user_id?.match /^[0-9a-f]{24}$/
next()
else
next new Error("invalid user id")
@@ -63,6 +63,14 @@ app.get "/project/:project_id/sync/pdf", CompileController.syncFromPdf
app.get "/project/:project_id/wordcount", CompileController.wordcount
app.get "/project/:project_id/status", CompileController.status
# Per-user containers
app.post "/project/:project_id/user/:user_id/compile", bodyParser.json(limit: "5mb"), CompileController.compile
# app.delete "/project/:project_id/user/:user_id", CompileController.clearCache
app.get "/project/:project_id/user/:user_id/sync/code", CompileController.syncFromCode
app.get "/project/:project_id/user/:user_id/sync/pdf", CompileController.syncFromPdf
app.get "/project/:project_id/user/:user_id/wordcount", CompileController.wordcount
ForbidSymlinks = require "./app/js/StaticServerForbidSymlinks"
# create a static server which does not allow access to any symlinks