api

package
v0.0.0-...-707bc42 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthorizationPayloadKey = "authorization_payload"
)

Variables

View Source
var (
	ErrUserNotExists  = errors.New("user does not exist")
	ErrUserExists     = errors.New("user already exists")
	ErrInvalidAddress = errors.New("invalid address")
	ErrInvalidNonce   = errors.New("invalid nonce")
	ErrMissingSig     = errors.New("signature is missing")
	ErrAuthError      = errors.New("authentication error")
)

Functions

func Authenticate

func Authenticate(server *Server, c echo.Context, wallet string, sigHex string) (db.GetUserByWalletAddressRow, error)

func GetNonce

func GetNonce() (string, error)

func HealthCheck

func HealthCheck(c echo.Context) error

HealthCheck godoc @Summary Show the status of server. @Description get the status of server. @Tags health @Accept */* @Produce json @Success 200 {object} map[string]interface{} @Router /health [get]

Types

type AdminResponse

type AdminResponse struct {
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
	Error   interface{} `json:"error"`
}

type CheckBlocklistsPayload

type CheckBlocklistsPayload struct {
	UUID string `json:"uuid"`
}

type CheckPayload

type CheckPayload struct {
	Address string `json:"address"`
}

func (CheckPayload) Validate

func (ch CheckPayload) Validate() error

type CheckUriPayload

type CheckUriPayload struct {
	Uri string `json:"uri"`
}

type DisprovePayload

type DisprovePayload struct {
	UUID string `json:"uuid"`
}

type EthUsdPrice

type EthUsdPrice struct {
	Usd float64 `json:"USD"`
}

type GasInfo

type GasInfo struct {
	Average   string `json:"average"`
	CreatedAt string `json:"createdAt"`
}

type GasPrices

type GasPrices struct {
	Average string `json:"result"`
}

type GetListPayload

type GetListPayload struct {
	UUID string `json:"uuid"`
}

type IffIdPayload

type IffIdPayload struct {
	IffId string `json:"iffid"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type NFTMetadataRequest

type NFTMetadataRequest struct {
	RefreshCache bool    `json:"refreshCache"`
	Tokens       []Token `json:"tokens"`
}

type RegisterPayload

type RegisterPayload struct {
	Wallet string `json:"wallet"`
}

func (RegisterPayload) Validate

func (p RegisterPayload) Validate() error

type Response

type Response struct {
	Page     int         `json:"page"`
	PageSize int         `json:"page_size"`
	Cursor   interface{} `json:"cursor"`
	Result   []Result    `json:"result"`
}

type Result

type Result struct {
	TokenID       string `json:"token_id"`
	MinterAddress string `json:"minter_address"`
}

type Server

type Server struct {
	Echo *echo.Echo
	// contains filtered or unexported fields
}

Server serves HTTP requests for our nft-platform service.

func NewServer

func NewServer(config util.Config, store db.Store) (*Server, error)

NewServer creates a new HTTP server and set up routing.

func (*Server) AdminLogin

func (server *Server) AdminLogin(e echo.Context) error

func (*Server) AuthMiddleware

func (server *Server) AuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc

AuthMiddleware creates an echo middleware for authorization

func (*Server) CheckBlocklists

func (server *Server) CheckBlocklists(c echo.Context) (err error)

blocklists godoc @Summary CheckBlocklists @Description fetch blocklist by uri @Tags CheckBlocklists @param uuid body string true "uuid" @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /checkBlocklists [POST]

func (*Server) CheckExistBlocklists

func (server *Server) CheckExistBlocklists(c echo.Context) (err error)

blocklists godoc @Summary CheckExistBlocklists @Description fetch blocklist by uri @Tags CheckExistBlocklists @param uri body string true "uri" @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /checkExistBlocklists [POST]

func (*Server) CheckSpamContract

func (server *Server) CheckSpamContract(c echo.Context) (err error)

nft godoc @Summary checkSpamContract @Description fetch limited IffNft @Tags checkSpamContract @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /checkSpamContract [POST]

func (*Server) DeleteUser

func (server *Server) DeleteUser(e echo.Context) error

func (*Server) DisproveBlocklist

func (server *Server) DisproveBlocklist(c echo.Context) (err error)

blocklists godoc @Summary DisproveBlocklist @Description disprove blocklist by uuid @Tags DisproveBlocklist @param uuid body string true "uuid" @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /api/disproveBlocklist [POST]

func (*Server) EthToUsd

func (server *Server) EthToUsd(c echo.Context) (err error)

ethToUsd godoc @Summary ethToUsd @Description get current 1 ETH to USD price @Tags ethToUsd @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /ethToUsd [GET]

func (*Server) FetchIffNftById

func (server *Server) FetchIffNftById(c echo.Context) (err error)

nft godoc @Summary fetchIffNftById @Description fetch limited IffNft @Tags getIffNftById @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /fetchIffNftById [POST]

func (*Server) FetchIffNftMeta

func (server *Server) FetchIffNftMeta(c echo.Context) (err error)

nft godoc @Summary getIffNftMeta @Description fetch limited IffNft @Tags getIffNftMeta @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /getIffNftMeta [GET]

func (*Server) FetchUserIffNfts

func (server *Server) FetchUserIffNfts(c echo.Context) (err error)

nft godoc @Summary fetchUserIffNfts @Description get USER IffNFTS @Tags fetchUserIffNfts @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /auth/fetchUserIffNfts [POST]

func (*Server) FetchUserNfts

func (server *Server) FetchUserNfts(c echo.Context) (err error)

mintit godoc @Summary fetchUserNfts @Description get mintable USER NFTS @Tags fetchUserNfts @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /auth/fetchUserNfts [POST]

func (*Server) GasHandler

func (server *Server) GasHandler(c echo.Context) (err error)

gasInfo godoc @Summary gasInfo @Description get every minutes gas prices @Tags gasInfo @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /gasInfo [GET]

func (*Server) GetAllBlockLists

func (server *Server) GetAllBlockLists(c echo.Context) (err error)

blocklists godoc @Summary getAllBlockLists @Description get all blocklists @Tags getAllBlockLists @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /api/getAllBlockLists [GET]

func (*Server) GetAllUsers

func (server *Server) GetAllUsers(e echo.Context) error

func (*Server) GetBlockListById

func (server *Server) GetBlockListById(c echo.Context) (err error)

blocklists godoc @Summary fetchBlockListById @Description fetch blocklist by uuid @Tags fetchBlockListById @param uuid body string true "uuid" @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /api/fetchBlockListById [POST]

func (*Server) GetBlocklistByUri

func (server *Server) GetBlocklistByUri(c echo.Context) (err error)

blocklists godoc @Summary checkUri @Description fetch blocklist by uri @Tags checkUri @param uri body string true "uri" @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /checkUri [POST]

func (*Server) ListDisprovedBlocklists

func (server *Server) ListDisprovedBlocklists(c echo.Context) (err error)

blocklists godoc @Summary ListDisprovedBlocklists @Description get all disproved blocklists @Tags ListDisprovedBlocklists @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /api/listDisprovedBlocklists [GET]

func (*Server) ListNftProjects

func (server *Server) ListNftProjects(c echo.Context) error

nft godoc @Summary nftProjects @Description fetch limited nft projects @Tags nftProjects @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /nftProjects [GET]

func (*Server) ListUnreviewedBlocklists

func (server *Server) ListUnreviewedBlocklists(c echo.Context) (err error)

blocklists godoc @Summary ListUnreviewedBlocklists @Description get all unreviewed blocklists @Tags ListUnreviewedBlocklists @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /api/listUnreviewedBlocklists [GET]

func (*Server) ListVerifiedBlocklists

func (server *Server) ListVerifiedBlocklists(c echo.Context) (err error)

blocklists godoc @Summary ListVerifiedBlocklists @Description fetch verified blocklists @Tags ListVerifiedBlocklists @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /api/listVerifiedBlocklists [GET]

func (*Server) LoginHandler

func (server *Server) LoginHandler(c echo.Context) (err error)

login godoc @Summary login @Description login @Tags login @Accept json @produce application/json @param wallet body string true "wallet" @param signature body string true "signature" @Success 200 {string} StatusOK @Success 201 {string} StatusOK @Failure 400 {string} StatusBadRequest @Failure 404 {string} StatusNotFound @Failure 500 {string} StatusInternalServerError @Router /login [POST]

func (*Server) NewUser

func (server *Server) NewUser(e echo.Context) error

func (*Server) NonceHandler

func (server *Server) NonceHandler(c echo.Context) (err error)

code godoc @Summary code @Description register a new user @Tags code @Accept json @produce application/json @param wallet body string true "wallet" @Success 200 {string} StatusOK @Success 201 {string} StatusOK @Failure 400 {string} StatusBadRequest @Failure 404 {string} StatusNotFound @Failure 500 {string} StatusInternalServerError @Router /code [POST]

func (*Server) RunCronFetchGas

func (server *Server) RunCronFetchGas()

func (*Server) Start

func (server *Server) Start(address string) error

Start runs the HTTP server on a specific address.

func (*Server) UnlockChannel

func (server *Server) UnlockChannel(e echo.Context) error

blocklists godoc @Summary Unlock discord channel @Description unlock discord channel to allow report project @Tags Admin Page @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /discord/channel/unlock/:id [PATCH]

func (*Server) VerifyBlocklist

func (server *Server) VerifyBlocklist(c echo.Context) (err error)

blocklists godoc @Summary VerifyBlocklist @Description verify blocklist by uuid @Tags VerifyBlocklist @param uuid body string true "uuid" @Accept */* @produce application/json @Success 200 {string} StatusOK @Router /api/verifyBlocklist [POST]

type SigninPayload

type SigninPayload struct {
	Wallet    string `json:"wallet"`
	Signature string `json:"signature"`
}

func (SigninPayload) Validate

func (s SigninPayload) Validate() error

type Token

type Token struct {
	TokenId         string `json:"tokenId"`
	ContractAddress string `json:"contractAddress"`
	TokenType       string `json:"tokenType"`
}

type User

type User struct {
	Wallet string `json:"wallet"`
	Nonce  string `json:"nonce"`
}

type VerifyPayload

type VerifyPayload struct {
	UUID string `json:"uuid"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL