Skip to content

Instantly share code, notes, and snippets.

@chrillo
Last active October 11, 2015 16:26
Show Gist options
  • Save chrillo/3c2256d8c3223143b481 to your computer and use it in GitHub Desktop.
Save chrillo/3c2256d8c3223143b481 to your computer and use it in GitHub Desktop.
'use strict'
var express = require('express')
class TogglController {
constructor(options){
this.toggl = options.toggl
this.togglSync = options.togglSync
this.auth = options.auth
this.router = express.Router()
this.router.get('/sync', this.auth.requireSession, this.sync.bind(this))
this.router.get('/sync/project/:projectId', this.auth.requireSession, this.syncProjectTimeEntries.bind(this))
}
sync(req, res, next){
this.togglSync.syncWorkspaces()
.then(res.json.bind(res))
.catch(next)
}
syncProjectTimeEntries(req, res, next){
this.togglSync.syncProjectTimeEntries(req.params.projectId)
.then(res.json.bind(res))
.catch(next)
}
}
module.exports = TogglController
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment