👌 update server.routes.js

This commit is contained in:
ghalestrilo 2020-07-31 14:50:38 -03:00
parent d42f10e114
commit 862fe1a3ba
4 changed files with 6 additions and 52 deletions

View file

@ -35,7 +35,7 @@ class App extends React.Component {
return (
<div className="app">
{/* FIXME: remove false */}
{this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />}
{false && this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />}
{this.props.children}
</div>
);

View file

@ -27,7 +27,7 @@ const checkAuth = (store) => {
// TODO: This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called
const onRouteChange = (store) => {
const path = window.location.pathname;
if (path.includes('/mobile')) return;
if (path.includes('/mobile/preview')) return;
store.dispatch(stopSketch());
};

View file

@ -145,54 +145,4 @@ router.get('/:username/collections', (req, res) => {
});
// Mobile Routes
if (process.env.MOBILE_ENABLED) {
router.get('/mobile', (req, res) => res.send(renderIndex()));
router.get('/mobile/preview', (req, res) => res.send(renderIndex()));
router.get('/mobile/preferences', (req, res) => res.send(renderIndex()));
router.get('/mobile/:username/sketches', (req, res) => {
userExists(req.params.username, fallback404(res));
});
router.get('/mobile/:username/sketches/:project_id', (req, res) => {
projectForUserExists(req.params.username, req.params.project_id, fallback404(res));
});
router.get('/mobile/:username/assets', (req, res) => {
userExists(req.params.username, (exists) => {
const isLoggedInUser = req.user && req.user.username === req.params.username;
const canAccess = exists && isLoggedInUser;
return canAccess ?
res.send(renderIndex()) :
get404Sketch(html => res.send(html));
});
});
router.get('/mobile/:username/collections/create', (req, res) => {
userExists(req.params.username, (exists) => {
const isLoggedInUser = req.user && req.user.username === req.params.username;
const canAccess = exists && isLoggedInUser;
return canAccess ?
res.send(renderIndex()) :
get404Sketch(html => res.send(html));
});
});
router.get('/mobile/:username/collections', (req, res) => {
userExists(req.params.username, fallback404(res));
});
router.get('/mobile/:username/collections/create', (req, res) => {
userExists(req.params.username, fallback404(res));
});
router.get('/mobile/:username/collections/:id', (req, res) => {
collectionForUserExists(req.params.username, req.params.id, fallback404(res));
});
}
export default router;

View file

@ -132,6 +132,10 @@ app.get(
// isomorphic rendering
app.use('/', serverRoutes);
if (process.env.MOBILE_ENABLED) {
app.use('/mobile', serverRoutes);
}
app.use(assetRoutes);
app.use('/', embedRoutes);