From 6a11b30bc2f701aacfcb0417993e158597bb3a3f Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Wed, 19 Aug 2015 11:28:14 -0700 Subject: [PATCH] serve static assets before sessions --- server/boot/challenge.js | 10 +++------- server/middleware.json | 16 ++++++++-------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 761bcc9711..bf486c4e23 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -63,11 +63,13 @@ module.exports = function(app) { const findChallenge$ = observeMethod(Challenge, 'find'); // create a stream of all the challenges const challenge$ = findChallenge$(challengesQuery) + .doOnNext(() => debug('query challenges')) .flatMap(challenges => Observable.from(challenges)) .shareReplay(); // create a stream of challenge blocks const blocks$ = challenge$ + .doOnNext(() => debug('query challenges')) .map(challenge => challenge.toJSON()) // group challenges by block | returns a stream of observables .groupBy(challenge => challenge.block) @@ -128,18 +130,12 @@ module.exports = function(app) { app.use(router); function returnNextChallenge(req, res, next) { - - // find the user's current challenge and block - // look in that block and find the index of their current challenge - // if index + 1 < block.challenges.length - // serve index + 1 challenge - // otherwise increment block key and serve the first challenge in that block - // unless the next block is undefined, which means no next block let nextChallengeName = firstChallenge; const challengeId = req.user.currentChallenge ? req.user.currentChallenge.challengeId : 'bd7123c8c441eddfaeb5bdef'; + // find challenge return challenge$ .map(challenge => challenge.toJSON()) diff --git a/server/middleware.json b/server/middleware.json index 10d78033a0..2c791f8b93 100644 --- a/server/middleware.json +++ b/server/middleware.json @@ -2,6 +2,14 @@ "initial:before": { "loopback#favicon": { "params": "$!../public/favicon.ico" + }, + "loopback#static": { + "params": [ + "$!../public", + { + "maxAge": "86400000" + } + ] } }, "initial": { @@ -42,14 +50,6 @@ "routes": { }, "files": { - "loopback#static": { - "params": [ - "$!../public", - { - "maxAge": "86400000" - } - ] - } }, "final": { },