serve static assets before sessions

This commit is contained in:
Berkeley Martinez
2015-08-19 11:28:14 -07:00
parent ca80196412
commit 6a11b30bc2
2 changed files with 11 additions and 15 deletions

View File

@ -63,11 +63,13 @@ module.exports = function(app) {
const findChallenge$ = observeMethod(Challenge, 'find'); const findChallenge$ = observeMethod(Challenge, 'find');
// create a stream of all the challenges // create a stream of all the challenges
const challenge$ = findChallenge$(challengesQuery) const challenge$ = findChallenge$(challengesQuery)
.doOnNext(() => debug('query challenges'))
.flatMap(challenges => Observable.from(challenges)) .flatMap(challenges => Observable.from(challenges))
.shareReplay(); .shareReplay();
// create a stream of challenge blocks // create a stream of challenge blocks
const blocks$ = challenge$ const blocks$ = challenge$
.doOnNext(() => debug('query challenges'))
.map(challenge => challenge.toJSON()) .map(challenge => challenge.toJSON())
// group challenges by block | returns a stream of observables // group challenges by block | returns a stream of observables
.groupBy(challenge => challenge.block) .groupBy(challenge => challenge.block)
@ -128,18 +130,12 @@ module.exports = function(app) {
app.use(router); app.use(router);
function returnNextChallenge(req, res, next) { 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; let nextChallengeName = firstChallenge;
const challengeId = req.user.currentChallenge ? const challengeId = req.user.currentChallenge ?
req.user.currentChallenge.challengeId : req.user.currentChallenge.challengeId :
'bd7123c8c441eddfaeb5bdef'; 'bd7123c8c441eddfaeb5bdef';
// find challenge // find challenge
return challenge$ return challenge$
.map(challenge => challenge.toJSON()) .map(challenge => challenge.toJSON())

View File

@ -2,6 +2,14 @@
"initial:before": { "initial:before": {
"loopback#favicon": { "loopback#favicon": {
"params": "$!../public/favicon.ico" "params": "$!../public/favicon.ico"
},
"loopback#static": {
"params": [
"$!../public",
{
"maxAge": "86400000"
}
]
} }
}, },
"initial": { "initial": {
@ -42,14 +50,6 @@
"routes": { "routes": {
}, },
"files": { "files": {
"loopback#static": {
"params": [
"$!../public",
{
"maxAge": "86400000"
}
]
}
}, },
"final": { "final": {
}, },