Guest User

Untitled

a guest
Aug 2nd, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.37 KB | None | 0 0
  1. var express = require('express');
  2. var router = express.Router();
  3. var User = require('../models/user');
  4. var contact = require('../models/contact');
  5. var buyer = require('../models/buyer');
  6. /* GET home page. */
  7. router.get('/', function(req, res, next) {
  8. res.render('index', { title: 'Express' });
  9. });
  10.  
  11. router.get('/indexl', function(req, res, next) {
  12. res.render('indexl', { title: 'Express' });
  13. });
  14.  
  15. router.get('/contact-us', function(req, res, next) {
  16. res.render('contact-us', { title: 'Express' });
  17. });
  18.  
  19. router.get('/buynow', function(req, res, next) {
  20. res.render('buynow', { title: 'Express' });
  21. });
  22.  
  23.  
  24.  
  25. router.get('/contact-usl', function(req, res, next) {
  26. res.render('contact-usl', { title: 'Express' });
  27. });
  28.  
  29.  
  30. router.get('/avanger', function(req, res, next) {
  31. res.render('avanger', { title: 'Express' });
  32. })
  33. router.get('/dominar', function(req, res, next) {
  34. res.render('dominar', { title: 'Express' });
  35. })
  36.  
  37. router.get('/dominarl', function(req, res, next) {
  38. res.render('dominarl', { title: 'Express' });
  39. })
  40.  
  41.  
  42. router.get('/bajajpulsur', function(req, res, next) {
  43. res.render('bajajpulsur', { title: 'Express' });
  44. })
  45.  
  46. router.get('/bajajpulsurl', function(req, res, next) {
  47. res.render('bajajpulsurl', { title: 'Express' });
  48. })
  49.  
  50.  
  51. router.get('/royalhimalayan', function(req, res, next) {
  52. res.render('royalhimalayan', { title: 'Express' });
  53. })
  54.  
  55.  
  56. router.get('/royalhimalayanl', function(req, res, next) {
  57. res.render('royalhimalayanl', { title: 'Express' });
  58. })
  59.  
  60.  
  61. router.get('/suzukihayabusa', function(req, res, next) {
  62. res.render('suzukihayabusa', { title: 'Express' });
  63. })
  64.  
  65. router.get('/suzukihayabusal', function(req, res, next) {
  66. res.render('suzukihayabusal', { title: 'Express' });
  67. })
  68.  
  69.  
  70. router.get('/heropassionxpro', function(req, res, next) {
  71. res.render('heropassionxpro', { title: 'Express' });
  72. })
  73.  
  74.  
  75. router.get('/heropassionxprol', function(req, res, next) {
  76. res.render('heropassionxprol', { title: 'Express' });
  77. })
  78.  
  79.  
  80.  
  81. router.get('/gxr', function(req, res, next) {
  82. res.render('gxr', { title: 'Express' });
  83. })
  84.  
  85. router.get('/gxrl', function(req, res, next) {
  86. res.render('gxrl', { title: 'Express' });
  87. })
  88.  
  89.  
  90.  
  91. router.get('/xtreme', function(req, res, next) {
  92. res.render('xtreme', { title: 'Express' });
  93. })
  94.  
  95. router.get('/xtremel', function(req, res, next) {
  96. res.render('xtremel', { title: 'Express' });
  97. })
  98.  
  99.  
  100.  
  101. router.get('/thunderbird', function(req, res, next) {
  102. res.render('thunderbird', { title: 'Express' });
  103. })
  104.  
  105. router.get('/thunderbirdl', function(req, res, next) {
  106. res.render('thunderbirdl', { title: 'Express' });
  107. })
  108.  
  109.  
  110.  
  111. router.get('/splendor', function(req, res, next) {
  112. res.render('splendor', { title: 'Express' });
  113. })
  114.  
  115. router.get('/splendorl', function(req, res, next) {
  116. res.render('splendorl', { title: 'Express' });
  117. })
  118.  
  119.  
  120.  
  121.  
  122. router.get('/bullet', function(req, res, next) {
  123. res.render('bullet', { title: 'Express' });
  124. })
  125.  
  126. router.get('/bulletl', function(req, res, next) {
  127. res.render('bulletl', { title: 'Express' });
  128. })
  129.  
  130.  
  131. router.get('/suzukiintruder', function(req, res, next) {
  132. res.render('suzukiintruder', { title: 'Express' });
  133. })
  134.  
  135. router.get('/suzukiintruderl', function(req, res, next) {
  136. res.render('suzukiintruderl', { title: 'Express' });
  137. })
  138.  
  139.  
  140.  
  141.  
  142. router.get('/avangerl', function(req, res, next) {
  143. res.render('avangerl', { title: 'Express' });
  144. })
  145.  
  146.  
  147.  
  148.  
  149. router.get('/aboutus', function(req, res, next) {
  150. res.render('aboutus', { title: 'Express' });
  151. })
  152. router.get('/loginpage', function(req, res, next) {
  153. res.render('loginpage', { title: 'Express' });
  154. })
  155. router.get('/register', function(req, res, next) {
  156. res.render('register', { title: 'Express' });
  157. })
  158. router.get('/disclaimer', function(req, res, next) {
  159. res.render('disclaimer', { title: 'Express' });
  160. })
  161.  
  162. router.get('/disclaimerl', function(req, res, next) {
  163. res.render('disclaimerl', { title: 'Express' });
  164. })
  165.  
  166. router.post('/login', function(req, res) {
  167. var email = req.body.email;
  168. var user_password = req.body.user_password;
  169.  
  170. User.findOne({email:email, user_password: user_password}, function(err,user){
  171. if(err){
  172. console.log(err);
  173. return res.status(500).send('Some Error Occurred');
  174.  
  175. }
  176. if(!user){
  177. return res.status(404).send('Invalid User! Go back and try again. ');
  178. }
  179. return res.render('indexl') ;
  180. })
  181.  
  182. });
  183.  
  184. router.get('/logout', (req, res) => {
  185. if (req.cookies.user_sid) {
  186. res.clearCookie('user_sid');
  187. res.redirect('/');
  188. } else {
  189. res.redirect('/');
  190. }
  191. });
  192.  
  193.  
  194.  
  195. router.post('/register', function(req, res){
  196. var user_name = req.body.user_name;
  197. var first_name = req.body.first_name;
  198. var last_name = req.body.last_name;
  199. var user_password = req.body.user_password;
  200. var email= req.body.email;
  201. var contact_no = req.body.contact_no;
  202. var confirm_password = req.body.confirm_Password;
  203.  
  204. var newuser = new User();
  205. newuser.user_name=user_name;
  206. newuser.user_password=user_password;
  207. newuser.email=email;
  208. newuser.first_name=first_name;
  209. newuser.last_name=last_name;
  210. newuser.confirm_password=confirm_password;
  211. newuser.contact_no=contact_no;
  212.  
  213. newuser.save(function(err, savedUser){
  214.  
  215. if(err){
  216. console.log(err);
  217. return res.status(500).send();
  218.  
  219. }
  220. console.log("new user added")
  221. return res.status(200).send('Signed Up. Please go back and click login button .');
  222.  
  223. })
  224.  
  225.  
  226.  
  227. })
  228.  
  229.  
  230.  
  231.  
  232. router.post('/contact', function(req, res){
  233. var myname = req.body.myname;
  234.  
  235. var email= req.body.email;
  236. var phone = req.body.phone;
  237. var subject= req.body.subject;
  238. var message=req.body.message;
  239.  
  240. var newcontact = new contact();
  241. newcontact.myname=myname;
  242.  
  243. newcontact.email=email;
  244.  
  245. newcontact.phone=phone;
  246. newcontact.subject=subject;
  247. newcontact.message=message;
  248.  
  249. newcontact.save(function(err, savedcontact){
  250.  
  251. if(err){
  252. console.log(err);
  253. return res.status(500).send();
  254.  
  255. }
  256. console.log("new contact added")
  257. return res.status(200).send('Thanks for contacting us. We will connect to you shortly.You can now go back and continue purchasing.');
  258. })
  259.  
  260.  
  261.  
  262. })
  263.  
  264.  
  265.  
  266. router.post('/buyerform', function(req, res){
  267. var firstname = req.body.firstname;
  268.  
  269. var email= req.body.email;
  270. var address= req.body.address;
  271. var city = req.body.city;
  272. var state= req.body.state;
  273. var zip=req.body.zip;
  274. var bikemodel=req.body.bikemodel;
  275.  
  276. var newbuyer = new buyer();
  277. newbuyer.firstname=firstname;
  278.  
  279. newbuyer.email=email;
  280. newbuyer.address=address;
  281. newbuyer.city=city;
  282. newbuyer.state=state;
  283. newbuyer.zip=zip;
  284. newbuyer.bikemodel=bikemodel;
  285.  
  286. newbuyer.save(function(err, savedbuyer){
  287.  
  288. if(err){
  289. console.log(err);
  290. return res.status(500).send();
  291.  
  292. }
  293. console.log("new buyer added")
  294. return res.status(200).send('Holla! Your Bike has been booked . Keep your payment method ready at the time of delivery.');
  295. })
  296.  
  297.  
  298.  
  299. })
  300. // Get Homepage
  301. // router.get('/', ensureAuthenticated, function(req, res){
  302. // res.render('index');
  303. // });
  304.  
  305. // function ensureAuthenticated(req, res, next){
  306. // if(req.isAuthenticated()){
  307. // return next();
  308. // } else {
  309. // // req.flash('error_msg','You are not logged in');
  310. // res.redirect('/users/login');
  311. // }
  312. // }
  313.  
  314.  
  315. module.exports = router;
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. ...........................................................
Add Comment
Please, Sign In to add comment