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”。