Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
"github.com/thirdweb-dev/indexer/internal/middleware"

// Import the generated Swagger docs
_ "github.com/thirdweb-dev/indexer/docs"
config "github.com/thirdweb-dev/indexer/configs"
"github.com/thirdweb-dev/indexer/docs"
)

var (
Expand All @@ -31,11 +32,12 @@ var (
// @description API for querying blockchain transactions and events
// @license.name Apache 2.0
// @license.url https://github.com/thirdweb-dev/indexer/blob/main/LICENSE
// @host localhost:3000
// @BasePath /
// @Security BasicAuth
// @securityDefinitions.basic BasicAuth
func RunApi(cmd *cobra.Command, args []string) {
docs.SwaggerInfo.Host = config.Cfg.API.Host

r := gin.New()
r.Use(gin.Logger())
r.Use(gin.Recovery())
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func init() {
rootCmd.PersistentFlags().String("storage-main-clickhouse-password", "", "Clickhouse password for main storage")
rootCmd.PersistentFlags().String("storage-staging-clickhouse-username", "", "Clickhouse username for staging storage")
rootCmd.PersistentFlags().String("storage-staging-clickhouse-password", "", "Clickhouse password for staging storage")
rootCmd.PersistentFlags().String("api-host", "localhost:3000", "API host")
viper.BindPFlag("rpc.url", rootCmd.PersistentFlags().Lookup("rpc-url"))
viper.BindPFlag("rpc.blocks.blocksPerRequest", rootCmd.PersistentFlags().Lookup("rpc-blocks-blocksPerRequest"))
viper.BindPFlag("rpc.blocks.batchDelay", rootCmd.PersistentFlags().Lookup("rpc-blocks-batchDelay"))
Expand Down Expand Up @@ -120,6 +121,7 @@ func init() {
viper.BindPFlag("storage.orchestrator.redis.addr", rootCmd.PersistentFlags().Lookup("storage-orchestrator-redis-addr"))
viper.BindPFlag("storage.orchestrator.redis.password", rootCmd.PersistentFlags().Lookup("storage-orchestrator-redis-password"))
viper.BindPFlag("storage.orchestrator.redis.db", rootCmd.PersistentFlags().Lookup("storage-orchestrator-redis-db"))
viper.BindPFlag("api.host", rootCmd.PersistentFlags().Lookup("api-host"))
rootCmd.AddCommand(orchestratorCmd)
rootCmd.AddCommand(apiCmd)
}
Expand Down
5 changes: 5 additions & 0 deletions configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ type RPCConfig struct {
Traces RPCTracesConfig `mapstructure:"traces"`
}

type APIConfig struct {
Host string `mapstructure:"host"`
}

type Config struct {
RPC RPCConfig `mapstructure:"rpc"`
Log LogConfig `mapstructure:"log"`
Poller PollerConfig `mapstructure:"poller"`
Committer CommitterConfig `mapstructure:"committer"`
FailureRecoverer FailureRecovererConfig `mapstructure:"failureRecoverer"`
Storage StorageConfig `mapstructure:"storage"`
API APIConfig `mapstructure:"api"`
}

var Cfg Config
Expand Down
2 changes: 1 addition & 1 deletion docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ const docTemplate = `{
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "v0.0.1-beta",
Host: "localhost:3000",
Host: "",
BasePath: "/",
Schemes: []string{},
Title: "Thirdweb Insight",
Expand Down
1 change: 0 additions & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
},
"version": "v0.0.1-beta"
},
"host": "localhost:3000",
"basePath": "/",
"paths": {
"/{chainId}/events": {
Expand Down
1 change: 0 additions & 1 deletion docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ definitions:
value:
type: string
type: object
host: localhost:3000
info:
contact: {}
description: API for querying blockchain transactions and events
Expand Down
Loading