Package: zpy-api-core
ZPy Core, Layer for build microservicesZPy CoreZurck'z Py Flask Micro Services CoreThis package contains some helpers features for build python microservices using Flask frameworkZPy use the following packages:Flaskmarshmallowmarshmallow_objectsrequestsaws-lambda-wsgiRequirementsPython 3.6+InstallationUse the package managerpipto install py flask micro service core .pipinstallzpy-api-coreFeaturesContains some helper features.ApiApi BuilderResponse BuilderModelsHooksMiddlewaresExceptionsCloud ImplementationsAws Handler decoratorsSee: AWS PackageCLIDDD Project structure generatorBounded Context GeneratorUseCases generatorDatabaseSee: SQL Oracle & MySQLLoggerStreamUtilsCollectionselement finderDatesTime zonesTransformsCiphersSee: Crypto WrappersFunctionsParallelmap parallelrun parallelObjectsgzipBasic UsageGenerate project usingzpy CLI# Generate project with basic information. for more type: zpy --helpzpymake-pawesome-api-d"My awsome users api"-cUsers-ucUserSearcher-op
...cdawesome-apizpy will generate the project with the following structureawesome-api
│   .env
│   .gitignore
│   CHANGELOG.md
│   CHANGELOG.md
│   README.md
│   requirements.txt    
│
└───src
│   │   di.py
│   │   handler.py
│   │   local_deploy.py
│   │
│   └───┬api
│       │   routes.py
│       │   ...
│       └contexts
│       │   ...
│       └───users
│         │   ...
│         └───┬application
│         │   │ ...
│         └───┬domain
│         │   │ ...
│         └───┬infraestructure
│             │ ...
└───tests
    │   user_searcher_test.pyDependencies file# 🛸 Generated by zPyfromzpy.utilsimportget_env_or_throwasvarfromzpy.app.usecaseimportUseCasefromtypingimportAny# * Setup Dependencies 📃fromcontexts.users.domain.repositoriesimportUserRepositoryfromcontexts.users.infraestructure.payment_repositoryimportAwesomeUserRepositoryfromcontexts.users.application.user_searcherimportUserSearcherrepository:UserRepository=AwesomeUserRepository()# Setup UseCasesuser_searcher_uc:UseCase[Any,None]=UserSearcher(repository)print("🚀 Dependencies loaded successfully...")routes.py# 🛸 Generated by zPyfromdiimportuser_searcher_ucfromflaskimportFlaskfromzpy.api.http.responseimportresponse_builderfromzpy.api.flaskimportcreate_appapp:Flask=create_app()@app.route("/api/users",methods=["GET"])@response_builderdefusers():returnuser_searcher_uc.execute(None)Use Case# 🛸 Generated by zPyfromtypingimportAnyfromzpy.app.usecaseimportUseCasefrom..domain.repositoriesimportUserRepositoryclassUserSearcher(UseCase[Any,Any]):"""Use Case description."""def__init__(self,repository:PaymentRepository)->None:self.repository=repositorydefexecute(self,data:Any,*args,**kwargs)->None:# TODO Do magic with business rules 😁returnself.repository.user_searcher(data)Local Dev Deploy# 🛸 Generated by zPyfromdotenvimportload_dotenvload_dotenv(dotenv_path="|3:\\projects\\demos\\awesome-api\\.env")fromapi.routesimportappif__name__=="__main__":app.run(host="127.0.0.1",port=5050,debug=True)handler.py configure for aws lambda and api gateway# 🛸 Generated by zPyfromzpy.api.cloud_handlersimportaws_lambdafromapi.routesimportappimportaws_lambda_wsgiasawsgi@aws_lambda()defhandle(event:dict,context:dict)->any:returnawsgi.response(app,event,context)ContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.LicenseMITAuthorsNoé Cruz