updated page routes

This commit is contained in:
bill bittner 2018-03-29 09:48:32 -07:00
parent daf6765f41
commit 1ad7c60b1a
7 changed files with 41 additions and 44 deletions

View file

@ -1,9 +0,0 @@
const handlePageRender = require('../../helpers/handlePageRender.jsx');
module.exports = app => {
// a catch-all route if someone visits a page that does not exist
app.use('*', (req, res) => {
// send response
handlePageRender(req, res);
});
};

View file

@ -0,0 +1,11 @@
const sendReactApp = require('./sendReactApp');
const sendEmbedPage = require('./sendEmbedPage');
const redirect = require('./redirect');
module.exports = {
sendReactApp,
sendEmbedPage,
redirect,
};

View file

@ -1,35 +0,0 @@
const { details: host } = require('../../../config/siteConfig.js');
const handlePageRender = require('../../helpers/handlePageRender.jsx');
module.exports = (app) => {
// route for the home page
app.get('/', (req, res) => {
handlePageRender(req, res);
});
// route to display login page
app.get('/login', (req, res) => {
handlePageRender(req, res);
});
// route to show 'about' page
app.get('/about', (req, res) => {
handlePageRender(req, res);
});
// route to display a list of the trending images
app.get('/trending', (req, res) => {
res.status(301).redirect('/popular');
});
app.get('/popular', (req, res) => {
handlePageRender(req, res);
});
// route to display a list of the trending images
app.get('/new', (req, res) => {
handlePageRender(req, res);
});
// route to send embedable video player (for twitter)
app.get('/embed/:claimId/:name', ({ params }, res) => {
const claimId = params.claimId;
const name = params.name;
// get and render the content
res.status(200).render('embed', { layout: 'embed', host, claimId, name });
});
};

View file

@ -0,0 +1,7 @@
const redirect = (route) => {
return (req, res) => {
res.status(301).redirect(route);
};
};
module.exports = redirect;

View file

@ -0,0 +1,12 @@
const { details: { host } } = require('siteConfig.js');
const sendEmbedPage = () => {
return ({ params }, res) => {
const claimId = params.claimId;
const name = params.name;
// get and render the content
res.status(200).render('embed', { layout: 'embed', host, claimId, name });
};
};
module.exports = sendEmbedPage;

View file

@ -0,0 +1,9 @@
const handlePageRender = require('helpers/handlePageRender.jsx');
const sendReactApp = () => {
return (req, res) => {
handlePageRender(req, res);
};
};
module.exports = sendReactApp;

View file

@ -1,6 +1,7 @@
const api = require('./server/routes/api/');
const asset = require('./server/routes/asset/');
const auth = require('./server/routes/auth/');
const fallback = require('./server/routes/fallback');
const logger = require('./config/loggerConfig.js');
const mysql = require('./config/mysqlConfig');
const site = require('./config/siteConfig');
@ -20,6 +21,7 @@ const exports = {
api,
asset,
auth,
fallback,
},
// Components,
};