2016-06-24 00:29:55 +02:00
|
|
|
import { Router } from 'express';
|
2016-11-17 17:15:35 +01:00
|
|
|
import { renderIndex } from '../views/index';
|
2017-01-06 21:05:02 +01:00
|
|
|
import { get404Sketch } from '../views/404Page';
|
2017-02-22 20:29:35 +01:00
|
|
|
import { userExists } from '../controllers/user.controller';
|
2017-06-01 06:08:11 +02:00
|
|
|
import { getProjectAsset } from '../controllers/project.controller';
|
2017-02-22 20:29:35 +01:00
|
|
|
|
|
|
|
const router = new Router();
|
2016-06-19 00:33:49 +02:00
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
// this is intended to be a temporary file
|
2016-06-19 00:33:49 +02:00
|
|
|
// until i figure out isomorphic rendering
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
router.route('/').get((req, res) => {
|
2016-11-09 00:11:12 +01:00
|
|
|
res.send(renderIndex());
|
2016-06-19 00:33:49 +02:00
|
|
|
});
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
router.route('/signup').get((req, res) => {
|
2017-09-29 20:52:20 +02:00
|
|
|
if (req.user) {
|
|
|
|
return res.redirect('/');
|
|
|
|
}
|
2017-10-16 05:27:05 +02:00
|
|
|
return res.send(renderIndex());
|
2016-06-19 00:33:49 +02:00
|
|
|
});
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
router.route('/projects/:project_id').get((req, res) => {
|
2016-11-09 00:11:12 +01:00
|
|
|
res.send(renderIndex());
|
2016-06-19 00:33:49 +02:00
|
|
|
});
|
|
|
|
|
2016-12-01 23:12:34 +01:00
|
|
|
router.route('/:username/sketches/:project_id').get((req, res) => {
|
|
|
|
res.send(renderIndex());
|
|
|
|
});
|
|
|
|
|
2017-06-12 19:49:45 +02:00
|
|
|
router.route('/:username/sketches/:project_id/*').get((req, res) => {
|
2017-10-16 05:27:05 +02:00
|
|
|
getProjectAsset(req, res);
|
2017-06-01 06:08:11 +02:00
|
|
|
});
|
|
|
|
|
2016-11-02 16:12:07 +01:00
|
|
|
// router.route('/full/:project_id').get((req, res) => {
|
2016-11-09 00:11:12 +01:00
|
|
|
// res.send(renderIndex());
|
2016-11-02 16:12:07 +01:00
|
|
|
// });
|
2016-08-18 00:13:17 +02:00
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
router.route('/login').get((req, res) => {
|
2017-09-29 20:52:20 +02:00
|
|
|
if (req.user) {
|
|
|
|
return res.redirect('/');
|
|
|
|
}
|
2017-10-16 05:27:05 +02:00
|
|
|
return res.send(renderIndex());
|
2016-06-19 00:33:49 +02:00
|
|
|
});
|
|
|
|
|
2016-10-12 18:02:46 +02:00
|
|
|
router.route('/reset-password').get((req, res) => {
|
2016-11-09 00:11:12 +01:00
|
|
|
res.send(renderIndex());
|
2016-10-12 18:02:46 +02:00
|
|
|
});
|
|
|
|
|
2016-10-18 22:07:25 +02:00
|
|
|
router.route('/reset-password/:reset_password_token').get((req, res) => {
|
2016-11-09 00:11:12 +01:00
|
|
|
res.send(renderIndex());
|
2016-10-18 22:07:25 +02:00
|
|
|
});
|
|
|
|
|
2017-06-26 18:48:28 +02:00
|
|
|
router.route('/verify').get((req, res) => {
|
|
|
|
res.send(renderIndex());
|
|
|
|
});
|
|
|
|
|
2016-07-05 22:04:14 +02:00
|
|
|
router.route('/sketches').get((req, res) => {
|
2016-11-09 00:11:12 +01:00
|
|
|
res.send(renderIndex());
|
2016-07-05 22:04:14 +02:00
|
|
|
});
|
|
|
|
|
2016-08-22 18:35:59 +02:00
|
|
|
router.route('/about').get((req, res) => {
|
2016-11-09 00:11:12 +01:00
|
|
|
res.send(renderIndex());
|
2016-08-22 18:35:59 +02:00
|
|
|
});
|
|
|
|
|
2016-08-17 21:53:25 +02:00
|
|
|
router.route('/:username/sketches').get((req, res) => {
|
2017-02-22 20:29:35 +01:00
|
|
|
userExists(req.params.username, exists => (
|
2017-01-06 19:08:03 +01:00
|
|
|
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
|
|
|
|
));
|
2016-08-17 21:53:25 +02:00
|
|
|
});
|
|
|
|
|
2017-07-11 17:37:43 +02:00
|
|
|
router.route('/:username/assets').get((req, res) => {
|
|
|
|
userExists(req.params.username, exists => (
|
|
|
|
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
|
|
|
|
));
|
|
|
|
});
|
|
|
|
|
2017-03-30 18:36:26 +02:00
|
|
|
router.route('/:username/account').get((req, res) => {
|
|
|
|
userExists(req.params.username, exists => (
|
|
|
|
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
|
|
|
|
));
|
|
|
|
});
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
export default router;
|