From 0da85d5d03272be4f4d5b6ec827ace125bd706af Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 19 May 2016 16:40:12 +0100 Subject: [PATCH] be ready to serve files from per-user containers --- app.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app.coffee b/app.coffee index 2a8e7b5..9f54f4a 100644 --- a/app.coffee +++ b/app.coffee @@ -42,6 +42,12 @@ 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_-]+$/ + next() + else + next new Error("invalid user id") + app.param 'build_id', (req, res, next, build_id) -> if build_id?.match OutputCacheManager.BUILD_REGEX next() @@ -72,6 +78,11 @@ staticServer = ForbidSymlinks express.static, Settings.path.compilesDir, setHead res.set("Etag", etag(path, stat)) res.set("Content-Type", ContentTypeMapper.map(path)) +app.get "/project/:project_id/user/:user_id/build/:build_id/output/*", (req, res, next) -> + # for specific build get the path from the OutputCacheManager (e.g. .clsi/buildId) + req.url = "/#{req.params.project_id}-#{req.params.user_id}/" + OutputCacheManager.path(req.params.build_id, "/#{req.params[0]}") + staticServer(req, res, next) + app.get "/project/:project_id/build/:build_id/output/*", (req, res, next) -> # for specific build get the path from the OutputCacheManager (e.g. .clsi/buildId) req.url = "/#{req.params.project_id}/" + OutputCacheManager.path(req.params.build_id, "/#{req.params[0]}")