Skip to content

futabooo/fitboxing2pixela

Repository files navigation

fitboxing2pixela

Fit Boxing 2のResult画面のスクショのURLを投稿するとPixelaに推定消費カロリーを記録するGoogle Cloud Functions(Cloud Run)です。

dartfnというDartでGoogle Cloud Functionsを使う時に便利なツールを使ってプロジェクトを作成しています。

ローカル環境での動作確認

Dockerを使用してローカル環境でFunctionをシミュレートすることができます。

環境変数の設定

.env.sampleから.envを作成します。

$ cp .env.sample .env

.envを編集して環境変数を設定します。

PIXELA_USER_TOKEN_KEYはSecretManagerのkey名を想定しています。

GCP_PROJECT={your_gcp_project_id}
PIXELA_USER_TOKEN_KEY={your_pixela_user_token_key}
PIXELA_USER_NAME={your_pixela_id}
PIXELA_GRAPH_ID={your_pixela_graph_id}

Dockerの実行

dockerでアプリケーションを実行します。

$ docker build -t fitboxing2pixela .
...

$ docker run -it -p 8080:8080 --name app fitboxing2pixela
Listening on :8080

Pixelaグラフへの追加

他のターミナルからcurlを実行してみるとPixelaのグラフに追加されます。

curl http://localhost:8080?url=https://pbs.twimg.com/media/FmXCf54aAAEQdWQ?format=jpg&name=large&date=2023-01-15T13:06:48.000Z

About

Cloudrun application records the quantity of fitboxing kcal date to Pixela

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published