calendar.js 716 Bytes
var express = require('express');
var router = express.Router();
var gcal = require('google-calendar');

router.post('/calendar',function(req,res,next){
    var id = req.body.id;
    res.render('calendar',{id: id});
});

calList = new Array();

router.get('/', function(req, res, next) {
  if(!req.session.googleToken) return res.redirect('/auth/google');
  else 

  googleToken = req.session.googleToken;
  kakaoToken = req.session.kakaoToken;

  gcal(googleToken).calendarList.list(function(err,data){
    if(err) return console.log(err);
    else {
      calList = data.items;
      res.render('calendar',{calList:calList,googleToken:googleToken,kakaoToken:kakaoToken});
    }
  });
});


module.exports = router;