Skip to content

Commit

Permalink
Added: front settings to backend config
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanSerikov authored and m-kus committed Jan 12, 2021
1 parent 81feb9e commit d96c639
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 60 deletions.
11 changes: 7 additions & 4 deletions cmd/api/handlers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 8 additions & 5 deletions cmd/api/handlers/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
4 changes: 4 additions & 0 deletions configs/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions configs/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions configs/sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions configs/you.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 22 additions & 29 deletions docker-compose.sandbox.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: "3.6"
services:
elastic:
container_name: sandbox-elastic
image: bakingbad/bcdhub-elastic:${TAG:-latest}
restart: always
volumes:
Expand All @@ -16,7 +15,6 @@ services:
max-file: "5"

mq:
container_name: sandbox-mq
image: rabbitmq:latest
restart: always
volumes:
Expand All @@ -27,7 +25,6 @@ services:
logging: *my-logging

db:
container_name: sandbox-db
image: postgres:12
restart: always
environment:
Expand All @@ -39,7 +36,6 @@ services:
logging: *my-logging

api:
container_name: sandbox-api
restart: always
image: bakingbad/bcdhub-api:${TAG:-latest}
build:
Expand All @@ -65,7 +61,6 @@ services:
logging: *my-logging

indexer:
container_name: sandbox-indexer
restart: always
image: bakingbad/bcdhub-indexer:${TAG:-latest}
build:
Expand All @@ -85,7 +80,6 @@ services:
logging: *my-logging

metrics:
container_name: sandbox-metrics
restart: always
image: bakingbad/bcdhub-metrics:${TAG:-latest}
build:
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 19 additions & 11 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
22 changes: 12 additions & 10 deletions internal/models/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -44,10 +45,10 @@ func AllDocuments() []string {
DocOperations,
DocProtocol,
DocSchema,
DocTZIP,
DocTezosDomains,
DocTokenBalances,
DocTransfers,
DocTZIP,
}
}

Expand All @@ -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{},
}
}

0 comments on commit d96c639

Please sign in to comment.