20bc8633d7
* Login and signup page not visible after login * Redirect added on server side
84 lines
2 KiB
JavaScript
84 lines
2 KiB
JavaScript
import { Router } from 'express';
|
|
import { renderIndex } from '../views/index';
|
|
import { get404Sketch } from '../views/404Page';
|
|
import { userExists } from '../controllers/user.controller';
|
|
import { getProjectAsset } from '../controllers/project.controller';
|
|
|
|
const router = new Router();
|
|
|
|
// this is intended to be a temporary file
|
|
// until i figure out isomorphic rendering
|
|
|
|
router.route('/').get((req, res) => {
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/signup').get((req, res) => {
|
|
if (req.user) {
|
|
return res.redirect('/');
|
|
}
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/projects/:project_id').get((req, res) => {
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/:username/sketches/:project_id').get((req, res) => {
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/:username/sketches/:project_id/*').get((req, res) => {
|
|
getProjectAsset(req,res);
|
|
});
|
|
|
|
// router.route('/full/:project_id').get((req, res) => {
|
|
// res.send(renderIndex());
|
|
// });
|
|
|
|
router.route('/login').get((req, res) => {
|
|
if (req.user) {
|
|
return res.redirect('/');
|
|
}
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/reset-password').get((req, res) => {
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/reset-password/:reset_password_token').get((req, res) => {
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/verify').get((req, res) => {
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/sketches').get((req, res) => {
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/about').get((req, res) => {
|
|
res.send(renderIndex());
|
|
});
|
|
|
|
router.route('/:username/sketches').get((req, res) => {
|
|
userExists(req.params.username, exists => (
|
|
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
|
|
));
|
|
});
|
|
|
|
router.route('/:username/assets').get((req, res) => {
|
|
userExists(req.params.username, exists => (
|
|
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
|
|
));
|
|
});
|
|
|
|
router.route('/:username/account').get((req, res) => {
|
|
userExists(req.params.username, exists => (
|
|
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
|
|
));
|
|
});
|
|
|
|
export default router;
|