From d96c6393e6b7da8b96959a2a8397393db7df8e7d Mon Sep 17 00:00:00 2001 From: Roman Serikov Date: Tue, 12 Jan 2021 20:00:24 +0300 Subject: [PATCH] Added: front settings to backend config --- cmd/api/handlers/config.go | 11 +++++--- cmd/api/handlers/responses.go | 13 +++++---- configs/development.yml | 4 +++ configs/production.yml | 4 +++ configs/sandbox.yml | 4 +++ configs/you.yml | 4 +++ docker-compose.sandbox.yml | 51 +++++++++++++++-------------------- docker-compose.yml | 1 - internal/config/config.go | 30 +++++++++++++-------- internal/models/consts.go | 22 ++++++++------- 10 files changed, 84 insertions(+), 60 deletions(-) diff --git a/cmd/api/handlers/config.go b/cmd/api/handlers/config.go index 2940cd3cd..bf032c81f 100644 --- a/cmd/api/handlers/config.go +++ b/cmd/api/handlers/config.go @@ -20,10 +20,13 @@ func (ctx *Context) GetConfig(c *gin.Context) { } cfg := ConfigResponse{ - Networks: ctx.Config.API.Networks, - OauthEnabled: ctx.Config.API.OAuthEnabled, - RPCEndpoints: rpcEndpoints, - TzKTEndpoints: tzktEndpoints, + Networks: ctx.Config.API.Networks, + OauthEnabled: ctx.Config.API.OAuthEnabled, + RPCEndpoints: rpcEndpoints, + TzKTEndpoints: tzktEndpoints, + GaEnabled: ctx.Config.API.Frontend.GaEnabled, + MempoolEnabled: ctx.Config.API.Frontend.MempoolEnabled, + SandboxMode: ctx.Config.API.Frontend.SandboxMode, } if ctx.Config.API.SentryEnabled { diff --git a/cmd/api/handlers/responses.go b/cmd/api/handlers/responses.go index c0962377e..a6f804317 100644 --- a/cmd/api/handlers/responses.go +++ b/cmd/api/handlers/responses.go @@ -576,11 +576,14 @@ type TransferResponse struct { // ConfigResponse - type ConfigResponse struct { - Networks []string `json:"networks"` - OauthEnabled bool `json:"oauth_enabled"` - RPCEndpoints map[string]string `json:"rpc_endpoints"` - TzKTEndpoints map[string]string `json:"tzkt_endpoints"` - SentryDSN string `json:"sentry_dsn"` + Networks []string `json:"networks"` + RPCEndpoints map[string]string `json:"rpc_endpoints"` + TzKTEndpoints map[string]string `json:"tzkt_endpoints"` + SentryDSN string `json:"sentry_dsn"` + OauthEnabled bool `json:"oauth_enabled"` + GaEnabled bool `json:"ga_enabled"` + MempoolEnabled bool `json:"mempool_enabled"` + SandboxMode bool `json:"sandbox_mode"` } // DApp - diff --git a/configs/development.yml b/configs/development.yml index cc9697fef..50e7b7623 100644 --- a/configs/development.yml +++ b/configs/development.yml @@ -79,6 +79,10 @@ api: oauth_enabled: true sentry_enabled: false seed_enabled: false + frontend: + ga_enabled: false + mempool_enabled: true + sandbox_mode: false networks: - mainnet - carthagenet diff --git a/configs/production.yml b/configs/production.yml index b61626919..bc09d221c 100644 --- a/configs/production.yml +++ b/configs/production.yml @@ -80,6 +80,10 @@ api: oauth_enabled: true sentry_enabled: true seed_enabled: false + frontend: + ga_enabled: true + mempool_enabled: true + sandbox_mode: false networks: - mainnet - carthagenet diff --git a/configs/sandbox.yml b/configs/sandbox.yml index cab4b2ede..333818cdf 100644 --- a/configs/sandbox.yml +++ b/configs/sandbox.yml @@ -32,6 +32,10 @@ api: oauth_enabled: false sentry_enabled: false seed_enabled: true + frontend: + ga_enabled: false + mempool_enabled: false + sandbox_mode: true seed: user: login: sandboxuser diff --git a/configs/you.yml b/configs/you.yml index 3af78b17d..5378b54d0 100644 --- a/configs/you.yml +++ b/configs/you.yml @@ -79,6 +79,10 @@ api: oauth_enabled: true sentry_enabled: true seed_enabled: false + frontend: + ga_enabled: false + mempool_enabled: true + sandbox_mode: false networks: - mainnet - carthagenet diff --git a/docker-compose.sandbox.yml b/docker-compose.sandbox.yml index 62d58a334..ee44bea88 100644 --- a/docker-compose.sandbox.yml +++ b/docker-compose.sandbox.yml @@ -1,7 +1,6 @@ version: "3.6" services: elastic: - container_name: sandbox-elastic image: bakingbad/bcdhub-elastic:${TAG:-latest} restart: always volumes: @@ -16,7 +15,6 @@ services: max-file: "5" mq: - container_name: sandbox-mq image: rabbitmq:latest restart: always volumes: @@ -27,7 +25,6 @@ services: logging: *my-logging db: - container_name: sandbox-db image: postgres:12 restart: always environment: @@ -39,7 +36,6 @@ services: logging: *my-logging api: - container_name: sandbox-api restart: always image: bakingbad/bcdhub-api:${TAG:-latest} build: @@ -65,7 +61,6 @@ services: logging: *my-logging indexer: - container_name: sandbox-indexer restart: always image: bakingbad/bcdhub-indexer:${TAG:-latest} build: @@ -85,7 +80,6 @@ services: logging: *my-logging metrics: - container_name: sandbox-metrics restart: always image: bakingbad/bcdhub-metrics:${TAG:-latest} build: @@ -107,36 +101,35 @@ services: sandbox: 172.17.0.1 logging: *my-logging -# flextesa: -# container_name: sandbox-flextesa -# restart: always -# image: tqtezos/flextesa:20200925 -# command: carthagebox start -# environment: -# - block_time=4 -# ports: -# - 127.0.0.1:8732:20000 -# logging: *my-logging + # flextesa: + # container_name: sandbox-flextesa + # restart: always + # image: tqtezos/flextesa:20200925 + # command: carthagebox start + # environment: + # - block_time=4 + # ports: + # - 127.0.0.1:8732:20000 + # logging: *my-logging -# jupyter: -# container_name: sandbox-jupyter -# restart: always -# image: bakingbad/bcdhub-jupyter:${TAG:-latest} -# build: -# context: . -# dockerfile: build/sandbox/jupyter/Dockerfile -# ports: -# - 127.0.0.1:8008:8008 -# extra_hosts: -# sandbox: 172.17.0.1 -# logging: *my-logging + # jupyter: + # container_name: sandbox-jupyter + # restart: always + # image: bakingbad/bcdhub-jupyter:${TAG:-latest} + # build: + # context: . + # dockerfile: build/sandbox/jupyter/Dockerfile + # ports: + # - 127.0.0.1:8008:8008 + # extra_hosts: + # sandbox: 172.17.0.1 + # logging: *my-logging gui: container_name: sandbox-gui restart: always image: bakingbad/bcdhub-gui:${TAG:-latest} entrypoint: /bin/bash - command: -c "mv config.sandbox.json config.production.json && nginx -g 'daemon off;'" depends_on: - api ports: diff --git a/docker-compose.yml b/docker-compose.yml index 027872ae7..29e9b361b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -113,7 +113,6 @@ services: command: >- -c "(cp /etc/bcd/nginx/default.${BCD_ENV:-production}.conf /etc/nginx/conf.d/default.conf || true) && (cp /etc/bcd/nginx/sitemap.${BCD_ENV:-production}.xml /usr/share/nginx/html/sitemap.xml || true) - && (mv config.${BCD_ENV:-production}.json config.production.json || true) && nginx -g 'daemon off;'" ports: - 127.0.0.1:${BCD_GUI_PORT}:80 diff --git a/internal/config/config.go b/internal/config/config.go index 224bd68bf..b518fd602 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -32,17 +32,18 @@ type Config struct { Domains TezosDomainsConfig `yaml:"domains"` API struct { - ProjectName string `yaml:"project_name"` - Bind string `yaml:"bind"` - SwaggerHost string `yaml:"swagger_host"` - CorsEnabled bool `yaml:"cors_enabled"` - OAuthEnabled bool `yaml:"oauth_enabled"` - SentryEnabled bool `yaml:"sentry_enabled"` - SeedEnabled bool `yaml:"seed_enabled"` - Seed SeedConfig `yaml:"seed"` - Networks []string `yaml:"networks"` - MQ MQConfig `yaml:"mq"` - Pinata PinataConfig `yaml:"pinata"` + ProjectName string `yaml:"project_name"` + Bind string `yaml:"bind"` + SwaggerHost string `yaml:"swagger_host"` + CorsEnabled bool `yaml:"cors_enabled"` + OAuthEnabled bool `yaml:"oauth_enabled"` + SentryEnabled bool `yaml:"sentry_enabled"` + SeedEnabled bool `yaml:"seed_enabled"` + Frontend FrontendConfig `yaml:"frontend"` + Seed SeedConfig `yaml:"seed"` + Networks []string `yaml:"networks"` + MQ MQConfig `yaml:"mq"` + Pinata PinataConfig `yaml:"pinata"` } `yaml:"api"` Compiler struct { @@ -135,6 +136,13 @@ type OAuthConfig struct { } `yaml:"gitlab"` } +// FrontendConfig - +type FrontendConfig struct { + GaEnabled bool `yaml:"ga_enabled"` + MempoolEnabled bool `yaml:"mempool_enabled"` + SandboxMode bool `yaml:"sandbox_mode"` +} + // SeedConfig - type SeedConfig struct { User struct { diff --git a/internal/models/consts.go b/internal/models/consts.go index 64fc0267f..28e57c7b7 100644 --- a/internal/models/consts.go +++ b/internal/models/consts.go @@ -9,6 +9,7 @@ import ( "github.com/baking-bad/bcdhub/internal/models/migration" "github.com/baking-bad/bcdhub/internal/models/operation" "github.com/baking-bad/bcdhub/internal/models/protocol" + "github.com/baking-bad/bcdhub/internal/models/schema" "github.com/baking-bad/bcdhub/internal/models/tezosdomain" "github.com/baking-bad/bcdhub/internal/models/tokenbalance" "github.com/baking-bad/bcdhub/internal/models/transfer" @@ -17,19 +18,19 @@ import ( // Document names const ( - DocContracts = "contract" - DocBlocks = "block" DocBalanceUpdates = "balance_update" - DocOperations = "operation" - DocBigMapDiff = "bigmapdiff" DocBigMapActions = "bigmapaction" - DocSchema = "schema" + DocBigMapDiff = "bigmapdiff" + DocBlocks = "block" + DocContracts = "contract" DocMigrations = "migration" + DocOperations = "operation" DocProtocol = "protocol" + DocSchema = "schema" + DocTezosDomains = "tezos_domain" + DocTokenBalances = "token_balance" DocTransfers = "transfer" DocTZIP = "tzip" - DocTokenBalances = "token_balance" - DocTezosDomains = "tezos_domain" ) // AllDocuments - returns all document names @@ -44,10 +45,10 @@ func AllDocuments() []string { DocOperations, DocProtocol, DocSchema, - DocTZIP, DocTezosDomains, DocTokenBalances, DocTransfers, + DocTZIP, } } @@ -62,9 +63,10 @@ func AllModels() []Model { &migration.Migration{}, &operation.Operation{}, &protocol.Protocol{}, + &schema.Schema{}, + &tezosdomain.TezosDomain{}, + &tokenbalance.TokenBalance{}, &transfer.Transfer{}, &tzip.TZIP{}, - &tokenbalance.TokenBalance{}, - &tezosdomain.TezosDomain{}, } }