generated from twin-te/grpc-ts-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,47 @@ | ||
# grpc-ts-template | ||
[![test](https://github.com/twin-te/user-service/actions/workflows/test.yml/badge.svg)](https://github.com/twin-te/timetable-service/actions/workflows/test.yml) | ||
|
||
typescript & grpc のテンプレート。 | ||
# twinte-user-service | ||
時間割アプリ Twin:te - https://app.twinte.net のv3バックエンドの一部です。 | ||
|
||
# 推奨開発環境 | ||
docker + vscode を使うことで簡単に開発可能。 | ||
ユーザー情報を管理します。 | ||
|
||
1. [RemoteDevelopment](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)拡張機能をインストール | ||
2. このプロジェクトのフォルダを開く | ||
3. 右下に `Folder contains a Dev Container configuration file. Reopen folder to develop in a container` と案内が表示されるので`Reopen in Container`を選択する。(表示されない場合はコマンドパレットを開き`open folder in container`と入力する) | ||
4. node14の開発用コンテナが立ち上がりVSCodeで開かれる。また、`.devcontainer/docker-compose.yml` に任意のサービスを追加するとvscode起動時に一緒に起動できる(データベース等)。 | ||
|
||
# npmコマンド一覧 | ||
|
||
|コマンド|説明| | ||
|:--|:--| | ||
|dev| 開発起動| | ||
|proto|protoファイルから型定義を生成(proto-gen.shを実行している)| | ||
|client|grpcリクエストが送れるCLIを起動| | ||
|test|テストを実行| | ||
|build|distにビルド結果を出力| | ||
|
||
# とりあえず動かす | ||
```bash | ||
# 準備 | ||
yarn && yarn proto | ||
|
||
# 開発鯖立ち上げ | ||
yarn dev | ||
|
||
|
||
## ----以下別窓---- ## | ||
|
||
# gRPCリクエストを送るCLIを立ち上げる | ||
yarn client | ||
# 利用方法 | ||
[ビルド済みDockerImage](https://github.com/orgs/twin-te/packages?repo_name=user-service)が利用できます。 | ||
|
||
# CLIが立ち上がったらリクエストを送る | ||
HelloService@localhost:50051> client.greet({name: 'Twin:te'}, pr) | ||
| 環境変数名 | 説明 | default | | ||
|------------|----------------------------------|-----------------------| | ||
| PG_HOST | Postgres接続先のホスト名 | postgres | | ||
| PG_PORT | Postgres接続先のポート番号 | 5432 | | ||
| PG_DATABASE | Postgres接続先のデータベース名 | twinte_user_service | | ||
| PG_USER | Postgres接続に使用するユーザー名 | postgres | | ||
| PG_PASSWORD | Postgres接続に使用するパスワード | postgres | | ||
| LOG_LEVEL | ログレベル fatal / error / warn / info / debug / trace / off | info | | ||
|
||
# レスポンスが返ってくれば成功 | ||
HelloService@localhost:50051> | ||
{ | ||
"text": "hello! SIY1121" | ||
} | ||
# 開発方法 | ||
Docker + VSCodeを推奨します。 | ||
以下その方法を紹介します。 | ||
|
||
``` | ||
|
||
# GitHub Actions | ||
- `.github/workflows/test.yml` pushされるとテストを実行する | ||
- `.github/workflows/release.yml` GitHub上でリリースをPublishするとDockerImageをビルドし、GHCRにプッシュする。 | ||
|
||
# 必要変更箇所 | ||
|
||
1. Dockerfile L17 | ||
```dockerfile | ||
LABEL org.opencontainers.image.source https://github.com/twin-te/grpc-ts-template | ||
``` | ||
後ろのurlを自分のレポジトリのurlに変更する。(DockerImageとレポジトリの紐付けを行う) | ||
|
||
2. .github/workflows/release.yml L17 | ||
```yml | ||
run: echo "TAG_NAME=ghcr.io/twin-te/grpc-ts-template:${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
``` | ||
TAG_NAME=ghcr.io/twin-te/{自分のレポジトリ名} に変更する(GitHubContainerRegistryにプッシュするときに使う) | ||
3. GitHubのSettings > Secrets > New repository secret で以下の環境変数を登録(GitHubAction用) | ||
|名前|説明| | ||
|:---|:---| | ||
|CR_PAT| GitHubContainerRegistry:write の権限を持ったPersonalAccessToken| | ||
|CR_USER|PersonalAccessTokenを作ったユーザー名| | ||
1. [RemoteDevelopment](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)拡張機能をインストール | ||
2. このプロジェクトのフォルダを開く | ||
3. 右下に `Folder contains a Dev Container configuration file. Reopen folder to develop in a container` と案内が表示されるので`Reopen in Container`を選択する。(表示されない場合はコマンドパレットを開き`open folder in container`と入力する) | ||
4. node14の開発用コンテナが立ち上がりVSCodeで開かれます。また、別途postgresも立ち上がり利用できるようになります。 | ||
5. `yarn install` で依存をインストールします。 | ||
6. `yarn proto` でgrpcに必要なファイルを生成します(開発中にprotoを変更した際も実行してください) | ||
7. `yarn dev` で立ち上がります。 | ||
|
||
また、`yarn test` でテストを実行、`yarn build` でビルドできます。 | ||
|
||
`yarn client`を実行するとcliでgrpcリクエストを送れる[grpcc](https://github.com/njpatel/grpcc)が利用できます。 | ||
|
||
# v3バックエンドサービス一覧 | ||
- [API Gateway](https://github.com/twin-te/api-gateway) | ||
- Auth Callback | ||
- **User Service** | ||
- Session Service | ||
- [Timetable Service](https://github.com/twin-te/timetable-service) | ||
- [Course Service](https://github.com/twin-te/course-service) | ||
- Search Service | ||
- Donation Service | ||
- School Calendar Service | ||
- Information Service | ||
- Task Service |