 app.post '/:name?/Recover'                      , require './handlers/recover'
 app.post '/:name?/Reset'                        , require './handlers/reset'
 app.post '/:name?/Optout'                       , require './handlers/optout'
+app.post '/:name?/OAuth'                        , require './oauth'
 app.post '/Impersonate/:nickname'               , require './handlers/impersonate'
 app.all '/:name?/Logout'                        , require './handlers/logout'
 # start webserver

app.get "/-/api/app/:app" , require "./applications"
app.get '/-/image/cache'  , require "./image_cache"

# Handlers for OAuth
app.get  "/-/oauth/odesk/callback"    , require  "./odesk_callback"
app.get  "/-/oauth/github/callback"   , require  "./github_callback"
app.get  "/-/oauth/facebook/callback" , require  "./facebook_callback"
app.get  "/-/oauth/google/callback"   , require  "./google_callback"
app.get  "/-/oauth/linkedin/callback" , require  "./linkedin_callback"
app.get  "/-/oauth/twitter/callback"  , require  "./twitter_callback"
app.post "/:name?/OAuth"              , require  "./oauth"
app.get  "/:name?/OAuth/url"          , require  "./oauth_url"

# Handlers for Payment
app.get  '/-/subscriptions'          , require "./subscriptions"
app.get  '/-/payments/paypal/return' , require "./paypal_return"
app.get  '/-/payments/paypal/cancel' , require "./paypal_cancel"
app.post '/-/payments/paypal/webhook', require "./paypal_webhook"
app.get  '/-/payments/customers'     , require "./customers"

isInAppRoute = (name)->
  [firstLetter] = name

app.use express.basicAuth basicAuth.username, basicAuth.password  if basicAuth


app.get '/-/oauth/odesk/callback'               , require './odesk_callback'
app.get '/-/oauth/github/callback'              , require './github_callback'
app.get '/-/oauth/facebook/callback'            , require './facebook_callback'
app.get '/-/oauth/google/callback'              , require './google_callback'
app.get '/-/oauth/linkedin/callback'            , require './linkedin_callback'
app.get '/-/oauth/twitter/callback'             , require './twitter_callback'
app.get '/-/payments/paypal/return'             , require './paypal_return'
app.get '/-/payments/paypal/cancel'             , require './paypal_cancel'
app.get '/-/payments/customers'                 , require './customers'
app.get '/-/presence/:service'                  , (req, res) -> res.status(200).end()
app.get '/-/subscriptions'                      , require './subscriptions'
app.get '/-/version'                            , (req, res) -> res.jsonp version: KONFIG.version
app.get '/-/healthCheck'                        , require './handlers/healthcheck'
app.get '/-/versionCheck'                       , require './handlers/versioncheck'
app.get '/:name?/OAuth/url'                     , require './oauth_url'
# redirects
app.get '/members/:username?*'                  , (req, res) -> res.redirect 301, "/#{req.params.username}"
app.get '/w/members/:username?*'                , (req, res) -> res.redirect 301, "/#{req.params.username}"
app.get '/activity/p/?*'                        , (req, res) -> res.redirect 301, '/Activity'
app.post '/-/payments/paypal/webhook'           , require './paypal_webhook'
app.post '/:name?/Validate'                     , require './handlers/validate'
app.post '/:name?/Validate/Username/:username?' , require './handlers/validateusername'
app.post '/:name?/Validate/Email/:email?'       , require './handlers/validateemail'
