feat(news): Initial server work for /news
This commit is contained in:
committed by
mrugesh mohapatra
parent
c84a9c8b57
commit
8ffd03578a
9
server/boot/news.js
Normal file
9
server/boot/news.js
Normal 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);
|
||||||
|
}
|
@ -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);
|
|
||||||
};
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
11
server/views/layout-news.jade
Normal file
11
server/views/layout-news.jade
Normal 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')))
|
@ -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')))
|
||||||
|
Reference in New Issue
Block a user