Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import {get, post, put, remove} from './requester.js';
  2. import * as authHandler from './handlers/auth-handler.js';
  3. import {setHeaderInfo, getPartials} from './shared.js';
  4.  
  5. (() => {
  6. const app = Sammy('#rooter', function () {
  7. this.use('Handlebars', 'hbs');
  8.  
  9. this.get('/', function (ctx) {
  10. setHeaderInfo(ctx);
  11. if(ctx.isAuth){
  12. get('appdata', 'recipes', 'Kinvey')
  13. .then((recipes) => {
  14. ctx.recipes = recipes;
  15.  
  16. this.loadPartials(getPartials())
  17. .partial('./views/home.hbs');
  18. });
  19. }else{
  20. this.loadPartials(getPartials())
  21. .partial('./views/home.hbs');
  22. }
  23. });
  24.  
  25. this.get('/register', authHandler.getRegister);
  26.  
  27. this.post('/register', authHandler.postRegister);
  28.  
  29. this.get('/login', authHandler.getLogin);
  30.  
  31. this.post('/login', authHandler.postLogin);
  32.  
  33. this.get('/logout', authHandler.logout);
  34.  
  35. });
  36. app.run();
  37. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement