index.js 879 B

123456789101112131415161718192021222324252627282930313233
  1. const express = require('express')
  2. const router = express.Router()
  3. const { fromTor, fromVpn, checkCountry } = require('./utils')
  4. // magic
  5. const render = (template, data) => (req, res) => res.render(template, data)
  6. router.get('/', render('index'))
  7. // level I (tor -> read metadata)
  8. router.get('/subito', fromTor,
  9. (req, res) => res.render(req.fromTor ? 'torok' : 'tornook') )
  10. // level II (read metadata -> mail)
  11. router.get('/metadata', render('metadata'))
  12. // level IV (mail -> vpn)
  13. router.get('/mail', render('mail'))
  14. // level V (vpn -> read mail)
  15. router.get('/vpn', fromTor, fromVpn, checkCountry, (req, res, next) => {
  16. console.log('son qui dentro');
  17. if (!req.fromTor && req.fromVpn) {
  18. res.render('vpnok', req.geoinfo);
  19. } else {
  20. res.render('vpnnook', req.geoinfo);
  21. }
  22. // console.log('sono qui dentro?!?!');
  23. // render('torok')
  24. })
  25. module.exports = router