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

串接大平台1 #93

Merged
merged 6 commits into from
Sep 19, 2023
Merged

串接大平台1 #93

merged 6 commits into from
Sep 19, 2023

Conversation

s9891326
Copy link
Collaborator

@s9891326 s9891326 commented Sep 6, 2023

先開發一部分issue內的東西

  • 串接大平台項目 #92
  • 新增API 心跳(/heath),固定回傳status = 200
  • 驗證JWT是否正確
  • 新增API 開始遊戲(/games),把既有的create_game()、join_game()、start_game()整合在同一支API中

@s9891326 s9891326 force-pushed the feature/add_lobby_start_game_api branch from 17dd4d6 to a8bbd8f Compare September 7, 2023 01:26
2. Add create jwt function to fix jwt_token expire problem
@@ -7,3 +7,8 @@
DB_PASSWORD = os.environ.get("DB_PASSWORD")
DB_NAME = os.environ.get("DB_NAME", "love_letter")
DB_COLLECTION = os.environ.get("DB_COLLECTION", "love_letter")
FRONTEND_HOST = os.environ.get("FRONTEND_HOST", "http://127.0.0.1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config 的內容,把它們收納成一個 class 或一個 object instance。
這樣統一 import 一個 class 或 object 就可以用了,不會讓參數那麼「零碎」。

Copy link
Collaborator Author

@s9891326 s9891326 Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

喔~ 看了自己寫的FRONTEND_HOST後,好像有點懂「零碎」的意思了,指的是這樣嗎~

# 原本import方式,可以直接得到想要的參數
from love_letter.config import FRONTEND_HOST
print(FRONTEND_HOST)

# 包進class並初始化後,只能透過該object才能抓到要的參數,增加了使用config時的約束力(一定要import這個object才能使用)
from love_letter.config import config
print(config.FRONTEND_HOST)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

對呦。這樣才不會需要超過 1 個以上的 import 來處理同時使用的問題

@@ -333,7 +333,8 @@ class Seen:


class Player:
def __init__(self, name: str):
def __init__(self, name: str, _id: Union[str] = None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_id 似乎沒有必要,大概是為了避內建的 id 嗎?如果 lint 沒有意見,那就保留,或改成 user_idaccount_idaccount 之類的。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

為了避開內建的id,我改成user_id好了

)
return True
except Exception as e:
print(e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

接近要上線的時刻,也許值得在追另新的 task,接上 sentry
https://sentry.io/welcome/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

酷~ 好喔,沒玩過之後來試試看

@s9891326 s9891326 merged commit d04e426 into master Sep 19, 2023
4 checks passed
@s9891326 s9891326 deleted the feature/add_lobby_start_game_api branch September 19, 2023 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants