updated page routes
This commit is contained in:
parent
daf6765f41
commit
1ad7c60b1a
7 changed files with 41 additions and 44 deletions
|
@ -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);
|
|
||||||
});
|
|
||||||
};
|
|
11
server/routes/page/index.js
Normal file
11
server/routes/page/index.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
const sendReactApp = require('./sendReactApp');
|
||||||
|
const sendEmbedPage = require('./sendEmbedPage');
|
||||||
|
const redirect = require('./redirect');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
sendReactApp,
|
||||||
|
sendEmbedPage,
|
||||||
|
redirect,
|
||||||
|
};
|
|
@ -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 });
|
|
||||||
});
|
|
||||||
};
|
|
7
server/routes/page/redirect.js
Normal file
7
server/routes/page/redirect.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
const redirect = (route) => {
|
||||||
|
return (req, res) => {
|
||||||
|
res.status(301).redirect(route);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = redirect;
|
12
server/routes/page/sendEmbedPage.js
Normal file
12
server/routes/page/sendEmbedPage.js
Normal 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;
|
9
server/routes/page/sendReactApp.js
Normal file
9
server/routes/page/sendReactApp.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
const handlePageRender = require('helpers/handlePageRender.jsx');
|
||||||
|
|
||||||
|
const sendReactApp = () => {
|
||||||
|
return (req, res) => {
|
||||||
|
handlePageRender(req, res);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = sendReactApp;
|
|
@ -1,6 +1,7 @@
|
||||||
const api = require('./server/routes/api/');
|
const api = require('./server/routes/api/');
|
||||||
const asset = require('./server/routes/asset/');
|
const asset = require('./server/routes/asset/');
|
||||||
const auth = require('./server/routes/auth/');
|
const auth = require('./server/routes/auth/');
|
||||||
|
const fallback = require('./server/routes/fallback');
|
||||||
const logger = require('./config/loggerConfig.js');
|
const logger = require('./config/loggerConfig.js');
|
||||||
const mysql = require('./config/mysqlConfig');
|
const mysql = require('./config/mysqlConfig');
|
||||||
const site = require('./config/siteConfig');
|
const site = require('./config/siteConfig');
|
||||||
|
@ -20,6 +21,7 @@ const exports = {
|
||||||
api,
|
api,
|
||||||
asset,
|
asset,
|
||||||
auth,
|
auth,
|
||||||
|
fallback,
|
||||||
},
|
},
|
||||||
// Components,
|
// Components,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue