kmilodenisglez / github.template-fabric.dapp-go

GitHub Template DApp for Hyperledger Fabric

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ›° GitHub Template DApp for Hyperledger Fabric

DApp to communicate with Hyperledger Fabric Blockchain Network

NOTE: This DApp has been tested on Ubuntu 18.04 and on Windows 10 with WSL and Golang 1.18 was used.

πŸ‘‰πŸΎ Read this doc to start DApp in dev mode.

Table of Contents

πŸ› οΈοΈ Configuration file (conf.yaml)

πŸ‘‰πŸΎ The config file

Param Description default value
APIDocIP IP to expose the api (unused) 127.0.0.1
DappPort app PORT 7001
CronEnabled active the cron job true
EveryTime time interval (in seconds) that the cron task is executed 300 seconds (every 5 minutes)

⚑ Get Started

Download the github.template-fabric.dapp-go project and move to root of project:

git clone https://github.com/kmilodenisglez/github.template-fabric.dapp-go.git && cd github.template-fabric.dapp-go 

πŸš€ Deployment ways (2 ways)

You can start the server in 2 ways, the first is using docker and docker-compose and the second is manually

πŸ“¦ Docker way

You will need docker and docker-compose in your system.

To builds Docker image from Dockerfile, run:

docker build --no-cache --force-rm --tag app_restapi .

Use docker-compose to start the container:

docker-compose up

πŸ”§ Manual way

Run:

go mod download
go mod vendor

If you make changes to the Endpoint you must generate Swagger API Spec:

swagger doc

Build:

go build

🌍 Environment variables

The environment variable is exported with the location of the server configuration file.

If you have 🐧Linux or 🍎Dash, run:

export SERVER_CONFIG=$PWD/conf/conf.yaml

but if it's the windows cmd, run:

set SERVER_CONFIG=%cd%/conf/conf.yaml

πŸƒπŸ½β€β™‚οΈ Start the server

Before it is recommended that you read more about the server configuration file in the section πŸ‘‰πŸΎ .

Run the server:

./github.template-fabric.dapp-go

and visit the swagger docs:

http://localhost:7001/swagger/index.html

swagger ui

You can then authenticate and test the remaining endpoints.

πŸ§ͺ Unit or End-To-End Testing

Run:

go test -v

πŸ”¨ Tech and packages

πŸ“ Architecture

This project has 3 layer :

  • Controller Layer (Presentation)
  • Service Layer (Business)
  • Repository Layer (Persistence)
Tag Path Layer
Auth end_auth.go Controller
Dapp end_dapp.go Controller
Auth svc_authentication.go Service
Dapp svc_dapp.go Service
Dapp repo_dapp.go Repository

πŸ“ Swagger

Read swagger doc

About

GitHub Template DApp for Hyperledger Fabric

License:GNU Lesser General Public License v2.1


Languages

Language:Go 98.4%Language:Dockerfile 1.2%Language:Shell 0.3%Language:Batchfile 0.1%