node.js - express.js with jade templating engine -
i have project i'm , i'm trying routing correct render jade file, golf.jade.
this routing.js file
var passport = require('passport'), http = require('http'), routes = require('./routes'), user = require('./routes/user'), game = require('./routes/game'), golf = require('./routes/golf'), webhooks = require('./routes/webhooks'); var mainapp = null; function ensureauthenticated(req, res, next) { if (req.isauthenticated()) return next(); res.set('x-auth-required', 'true'); //res.redirect('/login?returnurl=' + encodeduricomponent(req.originalurl)); res.redirect('/login'); } function ensureadmin(req, res, next) { if (req.user.canplayroleof('admin')) return next(); res.redirect('/'); } function ensureactive(req, res, next) { console.log("ensuring active"); if (req.user.active) return next(); res.redirect("/404"); } function ensureaccount(req, res, next) { if (req.user.email) return next(); //if (req.user.canplayroleof('account')) return next(); res.redirect('/account/externalconnect'); } function csrf(req, res, next) { res.locals.token = req.csrftoken(); next(); } exports = module.exports = function (app) { mainapp = app; routes.setmainapp(app); user.setmainapp(app); game.setmainapp(app); golf.setmainapp(app); webhooks.setmainapp(app); app.get('/ping.html', function (req, res) { res.render('ping'); }); app.get('/', csrf, ensureauthenticated, ensureactive, routes.index); app.get('/404', csrf, routes.pagemissing); app.get('/error', csrf, routes.error); //integration webhooks app.post("/partner/stripe/q12kp8vzlf", webhooks.stripe) //sports app.get('/:sport/week', csrf, ensureauthenticated, ensureactive, game.week); app.get('/:sport/coming', csrf, ensureauthenticated, ensureactive, routes.coming); //golf app.get('/:sport/golf', csrf, ensureauthenticated, ensureactive, golf); //results app.get('/:sport/results', csrf, ensureauthenticated, ensureactive, game.results); app.get('/:sport/results/:yr/getyearaccuracy', csrf, ensureauthenticated, ensureactive, game.getyearaccuracy); // game app.get('/:sport/game/:id', csrf, ensureauthenticated, ensureactive, game.game); app.get('/:sport/game/:id/info', csrf, ensureauthenticated, ensureactive, game.getgame); app.get('/:sport/game/:id/details', csrf, ensureauthenticated, ensureactive, game.getgamedetails); app.get('/:sport/game/:id/results', csrf, ensureauthenticated, ensureactive, game.getgameresults); app.get('/:sport/game/:id/predictions', csrf, ensureauthenticated, ensureactive, game.getgamepredictions); app.get('/:sport/game/:id/history', csrf, ensureauthenticated, ensureactive, game.getgamehistoryforteams); app.post('/:sport/game/:id/unlock', csrf, ensureauthenticated, ensureactive, game.unlockgame); // season app.get('/:sport/season/:yr/weeks', csrf, ensureauthenticated, ensureactive, game.getseasonweeks); app.get('/:sport/season/:yr/weeks/current', csrf, ensureauthenticated, ensureactive, game.getcurrentgameweek); app.get('/:sport/season/:yr/week/:wk', csrf, ensureauthenticated, ensureactive, game.getgameweek); app.get('/:sport/season/:yr/week/:wk/predictions', csrf, ensureauthenticated, ensureactive, game.getgameweekpredictions); app.get('/:sport/season/:yr/week/:wk/accuracy', csrf, ensureauthenticated, ensureactive, game.getgameweekaccuracy); app.get('/:sport/season/:yr/team/:id', csrf, ensureauthenticated, ensureactive, game.getteamseason); app.get('/:sport/season/:yr/week/:wk/unlocks', csrf, ensureauthenticated, ensureactive, game.getgameunlocksforuser); // profile app.get('/profile', csrf, ensureauthenticated, ensureactive, user.profile); app.get('/profile/data', csrf, ensureauthenticated, ensureactive, user.getprofile); app.post('/profile/save', csrf, ensureauthenticated, ensureactive, user.saveprofile); // subscription app.post('/profile/subscribe', csrf, ensureauthenticated, ensureactive, user.subscribe); app.get('/profile/subscriptions/available', csrf, ensureauthenticated, ensureactive, user.getsubscriptions); app.get('/profile/subscriptions/current', csrf, ensureauthenticated, ensureactive, user.getusersubscription); // billing app.get('/profile/billing/current', csrf, ensureauthenticated, ensureactive, user.getbillinginfo); // registration app.get('/register', csrf, user.register); app.post('/registeruser', csrf, user.registeruser); //forgot password app.get('/forgot', csrf, user.forgot); app.post('/resetaccount', csrf, user.resetaccount); app.post('/updatepassword', csrf, ensureauthenticated, ensureactive, user.updatepassword); // login app.get('/logout', csrf, user.logout); app.get('/login', csrf, user.login); app.post('/login', csrf, function (req, res, next) { passport.authenticate('local', function (err, user, info) { if (err) { return next(err); } if (!user) { req.session.message = [info.message]; return res.json({ result: { code: 2, title: "invalid login", message: "the username , password combination not recognized. [" + info.message + "]" } }); } req.login(user, function (err) { if (err) { return next(err); } return res.json({ result: { code: 0 } }); //return res.redirect('/'); }); })(req, res, next); }); };
my app.js file main file epress project references file. new node.js/express.js jade templating. i'm hoping figure out need change or add routes work correctly. have golf.jade template in views folder i'm trying link to.
hoping figure out have looked , tried every tutorial can find, looking direction, in advance
__scott
Comments
Post a Comment