From 272589ba344c54835ad229086ea947438ec0ef4c Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 26 Mar 2013 13:17:53 +0100 Subject: moved the routerfile. don't need a folder for one file. --- app.js | 2 +- router.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ routes/router.js | 64 -------------------------------------------------------- 3 files changed, 65 insertions(+), 65 deletions(-) create mode 100644 router.js delete mode 100644 routes/router.js diff --git a/app.js b/app.js index 93dde0d..20ef187 100644 --- a/app.js +++ b/app.js @@ -41,7 +41,7 @@ app.configure('development', function(){ * Routes */ -require('./routes/router')(app); +require('./router')(app); diff --git a/router.js b/router.js new file mode 100644 index 0000000..d0442b8 --- /dev/null +++ b/router.js @@ -0,0 +1,64 @@ + + + + + + + +module.exports = function(app) { + /* + * GET home page. + * + * '/' + */ + + app.get('/', function(req, res){ + // check if the user's credentials are saved in a cookie + if (req.cookies.user == undefined || req.cookies.pass == undefined) { + res.render('index', { title: 'DERS' }); + } else { // appempt automatic login + AM.autoLogin(req.cookies.user, req.cookies.pass, function(o) { + if (o != null) { + req.session.user = o; + res.redirect('/account'); + } else { + res.render('index', { title: 'DERS' }); + } + }); + } + }); + + + /* + * GET login page + * + * '/login' + */ + + app.get('/login', function(req, res) { + res.render('login', { title: 'Logg inn' }); + }); + + + /* + * 404 ERROR + */ + + app.get('*', function(req, res) { + res.render('error/404', { title: 'Fant ikke siden' }); + }); + + + + + + + + + + + + + + +} diff --git a/routes/router.js b/routes/router.js deleted file mode 100644 index d0442b8..0000000 --- a/routes/router.js +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - -module.exports = function(app) { - /* - * GET home page. - * - * '/' - */ - - app.get('/', function(req, res){ - // check if the user's credentials are saved in a cookie - if (req.cookies.user == undefined || req.cookies.pass == undefined) { - res.render('index', { title: 'DERS' }); - } else { // appempt automatic login - AM.autoLogin(req.cookies.user, req.cookies.pass, function(o) { - if (o != null) { - req.session.user = o; - res.redirect('/account'); - } else { - res.render('index', { title: 'DERS' }); - } - }); - } - }); - - - /* - * GET login page - * - * '/login' - */ - - app.get('/login', function(req, res) { - res.render('login', { title: 'Logg inn' }); - }); - - - /* - * 404 ERROR - */ - - app.get('*', function(req, res) { - res.render('error/404', { title: 'Fant ikke siden' }); - }); - - - - - - - - - - - - - - -} -- cgit v1.2.3