p5.js-web-editor/server/routes/server.routes.js
Basile Pesin 996a1b988a Fixes #692 (#713)
* Got the basis covered, now I need to style all this

* Corrected and upgraded Share window

* Changed the routes again, and set correct design

* Made some of the requested changes

* Removed PreviewFrame errors

* Redesigned Preview Header

* Corrected style of the FullView

* Corrected most of the css mistakes

* Corrected logo size
2018-10-18 14:10:37 -04:00

104 lines
2.5 KiB
JavaScript

import { Router } from 'express';
import { renderIndex } from '../views/index';
import { get404Sketch } from '../views/404Page';
import { userExists } from '../controllers/user.controller';
import { projectExists, projectForUserExists } from '../controllers/project.controller';
const router = new Router();
// this is intended to be a temporary file
// until i figure out isomorphic rendering
router.get('/', (req, res) => {
res.send(renderIndex());
});
router.get('/signup', (req, res) => {
if (req.user) {
return res.redirect('/');
}
return res.send(renderIndex());
});
router.get('/projects/:project_id', (req, res) => {
projectExists(req.params.project_id, exists => (
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
));
});
router.get('/:username/sketches/:project_id', (req, res) => {
projectForUserExists(req.params.username, req.params.project_id, exists => (
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
));
});
router.get('/:username/full/:project_id', (req, res) => {
projectForUserExists(req.params.username, req.params.project_id, exists => (
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
));
});
router.get('/full/:project_id', (req, res) => {
projectExists(req.params.project_id, exists => (
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
));
});
router.get('/login', (req, res) => {
if (req.user) {
return res.redirect('/');
}
return res.send(renderIndex());
});
router.get('/reset-password', (req, res) => {
res.send(renderIndex());
});
router.get('/reset-password/:reset_password_token', (req, res) => {
res.send(renderIndex());
});
router.get('/verify', (req, res) => {
res.send(renderIndex());
});
router.get('/sketches', (req, res) => {
if (req.user) {
res.send(renderIndex());
} else {
res.redirect('/login');
}
});
router.get('/assets', (req, res) => {
if (req.user) {
res.send(renderIndex());
} else {
res.redirect('/login');
}
});
router.get('/account', (req, res) => {
if (req.user) {
res.send(renderIndex());
} else {
res.redirect('/login');
}
});
router.get('/about', (req, res) => {
res.send(renderIndex());
});
router.get('/feedback', (req, res) => {
res.send(renderIndex());
});
router.get('/:username/sketches', (req, res) => {
userExists(req.params.username, exists => (
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
));
});
export default router;