Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cobble boot config #12

Merged
merged 2 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions boot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .stage1 import init_app as init_stage1
from .stage2 import init_app as init_stage2
from .auth import rebble, init_app as init_auth
from .cobble import init_app as init_cobble
from .settings import config

app = Flask(__name__)
Expand All @@ -34,6 +35,7 @@
init_stage1(app)
init_stage2(app)
init_auth(app)
init_cobble(app)

# XXX: upstream this
import beeline
Expand Down
33 changes: 33 additions & 0 deletions boot/cobble.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from flask import Blueprint, jsonify, request
import requests

from .settings import config

cobble = Blueprint('cobble', __name__)

@cobble.route('/')
def boot_cobble():
build = request.args.get('build')
platform = request.args.get('platform')
locale = request.args.get('locale', 'en_US')
boot = {
"auth": {
"base": f"{config['REBBLE_AUTH_URL']}/api",
"authorize_url": f"{config['REBBLE_AUTH_URL']}/oauth/authorise",
"refresh_url": f"{config['REBBLE_AUTH_URL']}/oauth/token",
"client_id": config['COBBLE_OAUTH_CLIENT_ID']
},
"appstore": {
"base": f"{config['APPSTORE_API_URL']}/api"
},
"webviews": {
"appstoreApplication": f"{config['APPSTORE_URL']}/{locale}/application/",
"appstoreWatchapps": f"{config['APPSTORE_URL']}/{locale}/watchapps",
"appstoreWatchfaces": f"{config['APPSTORE_URL']}/{locale}/watchfaces",
"manageAccount": config['REBBLE_ACCOUNT_URL']
}
}
return jsonify(boot)

def init_app(app, prefix='/api/cobble'):
app.register_blueprint(cobble, url_prefix=prefix)
2 changes: 2 additions & 0 deletions boot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
},
'HONEYCOMB_KEY': environ.get('HONEYCOMB_KEY', None),
'WS_PROXY_URL': environ.get('WS_PROXY_URL', f'ws://dev-ws-proxy.{domain_root}'),
'COBBLE_OAUTH_CLIENT_ID': environ['COBBLE_OAUTH_CLIENT_ID'],
'REBBLE_ACCOUNT_URL': environ.get('REBBLE_ACCOUNT_URL', f"{http_protocol}://auth.{domain_root}/account/"),
}