feat(news): Initial server work for /news

This commit is contained in:
Stuart Taylor
2018-07-31 16:34:32 +01:00
committed by mrugesh mohapatra
parent c84a9c8b57
commit 8ffd03578a
5 changed files with 22 additions and 14 deletions

9
server/boot/news.js Normal file
View File

@ -0,0 +1,9 @@
export default function newsBoot(app) {
const router = app.loopback.Router();
router.get('/', (req, res) => {
res.render('layout-news', {title: 'Hello News?'});
});
app.use('/news', router);
}

View File

@ -1,12 +0,0 @@
module.exports = function(app) {
const router = app.loopback.Router();
const redirectToReddit = (req, res) =>
res.redirect('https://www.reddit.com/r/FreeCodeCamp/');
router.get('/news', redirectToReddit);
router.get('/news/:storyName', redirectToReddit);
router.get('/stories/:storyName', redirectToReddit);
app.use(router);
};

View File

@ -31,7 +31,7 @@ export default function addReturnToUrl() {
req.method !== 'GET' || req.method !== 'GET' ||
pathsOfNoReturnRegex.test(path) || pathsOfNoReturnRegex.test(path) ||
!whiteListRegex.test(path) || !whiteListRegex.test(path) ||
(/news/i).test(path) && (/hot/i).test(req.path) (/hot/i).test(req.path)
) { ) {
return next(); return next();
} }

View File

@ -0,0 +1,11 @@
doctype html
html(lang='en')
head
if title
title= title
else
title freeCodeCamp
include partials/react-stylesheets
body
#news-app-mount
script(src=cacheBreaker(rev('/js', 'news-app.js')))

View File

@ -23,4 +23,4 @@ html(lang='en').full-size
fccTheme = null; fccTheme = null;
} }
})(); })();
script(src=cacheBreaker(rev('/js', 'bundle.js'))) script(src=cacheBreaker(rev('/js', 'client-app.js')))