Skip to content

Commit

Permalink
Removed dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed May 27, 2021
1 parent b4e46e0 commit 96c1460
Show file tree
Hide file tree
Showing 52 changed files with 16 additions and 3,722 deletions.
20 changes: 2 additions & 18 deletions cmd/api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ var doc = `{
},
{
"enum": [
"level",
"token_id",
"balance"
],
"type": "string",
Expand Down Expand Up @@ -3733,7 +3733,7 @@ var doc = `{
"type": "integer"
},
"network": {
"type": "string"
"type": "integer"
},
"protocol": {
"type": "string"
Expand Down Expand Up @@ -3881,14 +3881,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 @@ -4409,14 +4401,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
20 changes: 2 additions & 18 deletions cmd/api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
},
{
"enum": [
"level",
"token_id",
"balance"
],
"type": "string",
Expand Down Expand Up @@ -3715,7 +3715,7 @@
"type": "integer"
},
"network": {
"type": "string"
"type": "integer"
},
"protocol": {
"type": "string"
Expand Down Expand Up @@ -3863,14 +3863,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 @@ -4391,14 +4383,6 @@
"tx_count": {
"type": "integer",
"x-nullable": true
},
"verification_source": {
"type": "string",
"x-nullable": true
},
"verified": {
"type": "boolean",
"x-nullable": true
}
}
},
Expand Down
16 changes: 2 additions & 14 deletions cmd/api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ definitions:
level:
type: integer
network:
type: string
type: integer
protocol:
type: string
required:
Expand Down 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 Expand Up @@ -1672,7 +1660,7 @@ paths:
type: string
- description: Field using for sorting
enum:
- level
- token_id
- balance
in: query
name: sort_by
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 96c1460

Please sign in to comment.