diff src/routes.coffee @ 3:98a070c98982

add Twitter support
author Mathias Gebbe <mgebbe@intevation.de>
date Thu, 05 Jun 2014 18:02:25 +0200
parents b73191efc65b
children 2123f355ab68
line wrap: on
line diff
--- a/src/routes.coffee	Thu Jun 05 11:09:18 2014 +0200
+++ b/src/routes.coffee	Thu Jun 05 18:02:25 2014 +0200
@@ -1,10 +1,9 @@
 # Copyright (C) 2014 by Intevation GmbH
 # Author: Mathias Gebbe <mgebbe@intevation.de>
 #
-# This file is Free Software under the Apache License, Version 2.0
-# (the "License"); and comes with ABSOLUTELY NO WARRANTY!
-# You may not use this file except in compliance with the License.
-# See LICENSE for details.
+# This file is Free Software under the Apache License, Version 2.0;
+# and comes with NO WARRANTY!
+# See the documentation coming with pumpbridge for details.
 
 async = require("async")
 _ = require("underscore")
@@ -20,6 +19,7 @@
 Usermap = require("./usermap")
 Google = require("./google")
 Facebook = require("./facebook")
+Twitterroutes = require("./twitterroutes")
 Pump = require("./pumpio")
 User = require("./user")
 Edge = require("./edge")
@@ -51,7 +51,7 @@
 
 
     #### PUMPIO STUFF ####
-    if pumpid is "" or typeof pumpid is "undefined"
+    if not (pumpid?)
       console.log 'no pumpio'
     else
       saveUsermap(pumpid,pumpid,pumptoken+';'+pumpsecret,pumpsecret, (err, result) ->
@@ -65,7 +65,7 @@
 
 
     #### GOOGLE STUFF ####
-    if gpid is "" or typeof gpid is "undefined" or gptoken is "" or typeof gptoken is "undefined"
+    if not (gpid?) or not (gptoken?)
       console.log 'no google'
     else
       async.waterfall [
@@ -74,13 +74,13 @@
         (user, callback) ->
           Google.getRefreshToken(user,callback)
         (token, callback) ->
-          saveUsermap(pumpid,gpid,token.access_token+";"+gptoken.substr(gptoken.indexOf(';')+1 ,gptoken.lenght),token.refresh_token,callback)
+          saveUsermap(pumpid,gpid,token.access_token + ";" + gptoken.substr(gptoken.indexOf(';')+1,gptoken.length),token.refresh_token,callback)
       ], (err, result) ->
         # now we have a gp refresh token
         #console.log 'done'
 
     #### FACEBOOK STUFF ####
-    if fbid is "" or typeof fbid is "undefined" or fbtoken is "" or typeof fbtoken is "undefined"
+    if not (fbid?) or not (fbtoken?)
       console.log 'no facebook'
     else
     # get long-lived token
@@ -102,6 +102,7 @@
   # Routes
   app.get "/bridge", userAuth, userRequired, getBridge
   app.post "/bridge", userAuth, userRequired, saveBridge
+  Twitterroutes.addRoutes(app)
 
   return
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)