no framework api
1.0.0
一個使用食譜 API 服務的簡單應用程式。這是出於演示目的,旨在展示架構和程式設計技能。
以下是關鍵設計點,以及如何處理和實施。
開發環境要求:
使用安裝腳本在本機上設定開發環境:
$ git clone https://github.com/ahsanatiq/no-framework-api
$ cd ahsanatiq-api-test
$ git checkout dev
$ ./setup.sh
手動設定:
$ git clone https://github.com/ahsanatiq/no-framework-api
$ cd ahsanatiq-api-test
$ git checkout dev
$ cp recipe-service/.env.dev recipe-service/.env
$ cp oauth-service/.env.dev oauth-service/.env
$ cp search-service/.env.dev search-service/.env
$ cp web-service/.env.dev web-service/.env
$ docker-compose up -d
$ docker exec -it ahsanatiq-recipe-service composer install
$ docker exec -it ahsanatiq-oauth-service composer install
$ docker exec -it ahsanatiq-search-service composer install
$ docker exec -it ahsanatiq-web-service composer install
$ docker exec -it ahsanatiq-recipe-postgres createdb -U hellofresh -O hellofresh hellofresh_testing
$ docker exec -it ahsanatiq-postgres-oauth createdb -U hellofresh -O hellofresh hellofresh_testing
$ docker exec -it ahsanatiq-oauth-service openssl genrsa -out /server/keys/id_rsa 2048
$ docker exec -it ahsanatiq-oauth-service openssl rsa -in /server/keys/id_rsa -pubout -out /server/keys/id_rsa.pub
$ docker exec -it ahsanatiq-recipe-service php vendor/bin/phinx migrate
$ docker exec -it ahsanatiq-oauth-service php vendor/bin/phinx migrate
$ docker exec -it ahsanatiq-oauth-service php vendor/bin/phinx seed:run
$ docker exec -it ahsanatiq-oauth-service php vendor/bin/phinx migrate -e testing
$ docker exec -it ahsanatiq-oauth-service php vendor/bin/phinx seed:run -e testing
$ docker exec ahsanatiq-search-service nohup /usr/bin/php /server/http/console.php consume:recipes &
現在您可以透過 http://localhost:8000 存取該應用程式。
在 Recipe-Service 容器中執行單元測試:
$ docker exec -it ahsanatiq-recipe-service php vendor/bin/codecept run
在 Web 服務容器中執行驗收測試:
$ docker exec -it ahsanatiq-web-service php vendor/bin/codecept run
您可以在 Postman 上存取公共 API 文件。若要匯入並執行所有 API,請點擊頂部欄上的“在 Postman 中執行”,安裝並匯入後,您將看到新集合為“HelloFresh-Recipes API”。若要存取受保護的 API,您需要先從「驗證 -> 取得令牌」端點執行產生令牌。然後透過點擊郵差應用程式內的右上角來更新「HelloFresh-Dev」環境設定中的「access_Token」。