Saas Template
- Node.js: 14.x +
.env
をセットアップします。
AUTH0_ISSUER_URL
を正しい値に変更する。
$ cp api/.env.example api/.env
コンテナを起動します。
$ docker compose up
Prisma で Database を migrate します。
$ docker compose exec api npx prisma migrate dev
docker compose up
を実行すると、 start:dev
から NestJS の API が起動します。
$ cp client/.env.example client/.env
$ cd client
$ yarn # 依存関係を解消します
$ yarn dev # http://localhost:3000 で起動されます
URL | 解説 |
---|---|
http://localhost:8080 | api server |
http://localhost:3000 | client appication |
postgresql://postgres:password@db:5432/nestjs-prisma-nextjs | postgresql server |
💡 PostgreSQLのDBクライアントは、 TablePlus を使っています。
GCP Cloud Run にデプロイされます。
github -> cloud build -> cloud run
APIの確認は、 curl もしくは、 Postman API Platform をオススメします。 複雑な API は、 Postman が良いです。
オプション | 解説 |
---|---|
出力にHTTP応答ヘッダーを含めます | -i or -include |
HTTPメソッドの指定 | -X or --header |
ヘッダーの指定 | -H or --request |
データ指定 | -d or --data |
$ACCESS_TOKEN
はAuth0から取得します。
curl -X GET http://localhost:8080/users/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN"
curl -X PUT http://localhost:8080/users/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{"email": "example@gmail.com"}'
curl -X DELETE http://localhost:8080/users/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN"