Skip to content

Commit

Permalink
Removed dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jun 7, 2021
1 parent aeedb54 commit 4a5ddf0
Show file tree
Hide file tree
Showing 52 changed files with 10 additions and 3,717 deletions.
16 changes: 0 additions & 16 deletions cmd/api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3944,14 +3944,6 @@ var doc = `{
"tx_count": {
"type": "integer",
"x-nullable": true
},
"verification_source": {
"type": "string",
"x-nullable": true
},
"verified": {
"type": "boolean",
"x-nullable": true
}
}
},
Expand Down Expand Up @@ -4472,14 +4464,6 @@ var doc = `{
"tx_count": {
"type": "integer",
"x-nullable": true
},
"verification_source": {
"type": "string",
"x-nullable": true
},
"verified": {
"type": "boolean",
"x-nullable": true
}
}
},
Expand Down
16 changes: 0 additions & 16 deletions cmd/api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3926,14 +3926,6 @@
"tx_count": {
"type": "integer",
"x-nullable": true
},
"verification_source": {
"type": "string",
"x-nullable": true
},
"verified": {
"type": "boolean",
"x-nullable": true
}
}
},
Expand Down Expand Up @@ -4454,14 +4446,6 @@
"tx_count": {
"type": "integer",
"x-nullable": true
},
"verification_source": {
"type": "string",
"x-nullable": true
},
"verified": {
"type": "boolean",
"x-nullable": true
}
}
},
Expand Down
12 changes: 0 additions & 12 deletions cmd/api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,6 @@ definitions:
tx_count:
type: integer
x-nullable: true
verification_source:
type: string
x-nullable: true
verified:
type: boolean
x-nullable: true
type: object
handlers.CountResponse:
properties:
Expand Down Expand Up @@ -726,12 +720,6 @@ definitions:
tx_count:
type: integer
x-nullable: true
verification_source:
type: string
x-nullable: true
verified:
type: boolean
x-nullable: true
type: object
handlers.SimilarContractsResponse:
properties:
Expand Down
63 changes: 0 additions & 63 deletions cmd/api/handlers/auth.go

This file was deleted.

1 change: 0 additions & 1 deletion cmd/api/handlers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func (ctx *Context) GetConfig(c *gin.Context) {

cfg := ConfigResponse{
Networks: ctx.Config.API.Networks,
OauthEnabled: ctx.Config.API.OAuthEnabled,
RPCEndpoints: rpcEndpoints,
TzKTEndpoints: tzktEndpoints,
GaEnabled: ctx.Config.API.Frontend.GaEnabled,
Expand Down
25 changes: 0 additions & 25 deletions cmd/api/handlers/context.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package handlers

import (
"github.com/baking-bad/bcdhub/cmd/api/oauth"
"github.com/baking-bad/bcdhub/internal/config"
"github.com/gin-gonic/gin"
jsoniter "github.com/json-iterator/go"
)

Expand All @@ -12,24 +10,13 @@ var json = jsoniter.ConfigCompatibleWithStandardLibrary
// Context -
type Context struct {
*config.Context
OAUTH oauth.Config
}

// NewContext -
func NewContext(cfg config.Config) (*Context, error) {
var oauthCfg oauth.Config
if cfg.API.OAuthEnabled {
var err error
oauthCfg, err = oauth.New(cfg)
if err != nil {
return nil, err
}
}

ctx := config.NewContext(
config.WithStorage(cfg.Storage, cfg.API.ProjectName, int64(cfg.API.PageSize)),
config.WithRPC(cfg.RPC),
config.WithDatabase(cfg.DB),
config.WithSearch(cfg.Storage),
config.WithShare(cfg.SharePath),
config.WithTzKTServices(cfg.TzKT),
Expand All @@ -41,17 +28,5 @@ func NewContext(cfg config.Config) (*Context, error) {

return &Context{
Context: ctx,
OAUTH: oauthCfg,
}, nil
}

// CurrentUserID - return userID (uint) from gin context
func CurrentUserID(c *gin.Context) uint {
if val, ok := c.Get("userID"); ok && val != nil {
if userID, valid := val.(uint); valid {
return userID
}
}

return 0
}
22 changes: 3 additions & 19 deletions cmd/api/handlers/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/baking-bad/bcdhub/internal/models/contract"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
)

// GetContract godoc
Expand Down Expand Up @@ -39,7 +38,7 @@ func (ctx *Context) GetContract(c *gin.Context) {
return
}

res, err := ctx.contractPostprocessing(contract, c)
res, err := ctx.contractPostprocessing(contract)
if ctx.handleError(c, err, 0) {
return
}
Expand Down Expand Up @@ -74,32 +73,17 @@ func (ctx *Context) GetRandomContract(c *gin.Context) {
return
}

res, err := ctx.contractPostprocessing(contract, c)
res, err := ctx.contractPostprocessing(contract)
if ctx.handleError(c, err, 0) {
return
}
c.JSON(http.StatusOK, res)
}

func (ctx *Context) contractPostprocessing(contract contract.Contract, c *gin.Context) (Contract, error) {
func (ctx *Context) contractPostprocessing(contract contract.Contract) (Contract, error) {
var res Contract
res.FromModel(contract)

if userID, err := ctx.getUserFromToken(c); err == nil && userID != 0 {
if sub, err := ctx.DB.GetSubscription(userID, res.Address, contract.Network); err == nil {
subscription := PrepareSubscription(sub)
res.Subscription = &subscription
} else if !gorm.IsRecordNotFoundError(err) {
return res, err
}
}

if totalSubscribed, err := ctx.DB.GetSubscriptionsCount(res.Address, contract.Network); err == nil {
res.TotalSubscribed = totalSubscribed
} else {
return res, err
}

if alias, err := ctx.TZIP.Get(contract.Network, contract.Address); err == nil {
res.Slug = alias.Slug
} else if !ctx.Storage.IsRecordNotFound(err) {
Expand Down
Loading

0 comments on commit 4a5ddf0

Please sign in to comment.