<commit_before>express = require 'express'
bodyParser = require 'body-parser'
oauthserver = require 'oauth2-server'
OctobluOauth = require './octoblu-oauth'

OCTOBLU_BASE_URL = process.env.OCTOBLU_BASE_URL || 'https://app.octoblu.com'
OCTOBLU_OAUTH_PROVIDER_SERVER_PORT = process.env.OCTOBLU_OAUTH_PROVIDER_SERVER_PORT || 9000
MESHBLU_HOST = process.env.MESHBLU_HOST
MESHBLU_PORT = process.env.MESHBLU_PORT
MESHBLU_PROTOCOL = process.env.MESHBLU_PROTOCOL

app = express()

app.use bodyParser.urlencoded extended: true
app.use bodyParser.json()

app.oauth = oauthserver
  model: new OctobluOauth {server: MESHBLU_HOST, port: MESHBLU_PORT, protocol: MESHBLU_PROTOCOL}
  grants: [ 'authorization_code', 'client_credentials' ]
  debug: true

app.all '/access_token', app.oauth.grant()

app.get '/', (req, res) ->
  res.send online: true

app.get '/authorize', (req, res) ->
  res.redirect "#{OCTOBLU_BASE_URL}/oauth/#{req.query.client_id}?redirect=/auth_code&redirect_uri=#{req.query.redirect_uri}&response_type=#{req.query.response_type}"

app.get '/auth_code', app.oauth.authCodeGrant (req, next) =>
  next null, true, req.params.uuid, null

app.use app.oauth.errorHandler()

app.listen OCTOBLU_OAUTH_PROVIDER_SERVER_PORT<commit_msg>add healthcheck<commit_after>express = require 'express'
bodyParser = require 'body-parser'
oauthserver = require 'oauth2-server'
OctobluOauth = require './octoblu-oauth'

OCTOBLU_BASE_URL = process.env.OCTOBLU_BASE_URL || 'https://app.octoblu.com'
OCTOBLU_OAUTH_PROVIDER_SERVER_PORT = process.env.OCTOBLU_OAUTH_PROVIDER_SERVER_PORT || 9000
MESHBLU_HOST = process.env.MESHBLU_HOST
MESHBLU_PORT = process.env.MESHBLU_PORT
MESHBLU_PROTOCOL = process.env.MESHBLU_PROTOCOL

app = express()

app.use bodyParser.urlencoded extended: true
app.use bodyParser.json()

app.oauth = oauthserver
  model: new OctobluOauth {server: MESHBLU_HOST, port: MESHBLU_PORT, protocol: MESHBLU_PROTOCOL}
  grants: [ 'authorization_code', 'client_credentials' ]
  debug: true

app.all '/access_token', app.oauth.grant()

app.get '/healthcheck', (req, res) ->
  res.send online: true

app.get '/authorize', (req, res) ->
  res.redirect "#{OCTOBLU_BASE_URL}/oauth/#{req.query.client_id}?redirect=/auth_code&redirect_uri=#{req.query.redirect_uri}&response_type=#{req.query.response_type}"

app.get '/auth_code', app.oauth.authCodeGrant (req, next) =>
  next null, true, req.params.uuid, null

app.use app.oauth.errorHandler()

app.listen OCTOBLU_OAUTH_PROVIDER_SERVER_PORT
{'fraction_non_alphanumeric': 0.12848484848484848, 'fraction_numerical': 0.00404040404040404, 'mean_word_length': 6.15606936416185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4687650', 'n_tokens_mistral': 971, 'n_tokens_neox': 946, 'n_words': 155}