Skip to content

Commit

Permalink
feat: mock icy oracle (#3)
Browse files Browse the repository at this point in the history
* feat: mock icy oracle

* feat: add swagger to devbox

* feat: add swagger to devbox
  • Loading branch information
nnhuyhoang authored Nov 8, 2024
1 parent 6c5359b commit 64c7643
Show file tree
Hide file tree
Showing 16 changed files with 948 additions and 63 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ stop:
# Run the server
dev:
go run ./cmd/server/main.go

gen-swagger:
swag init --parseDependency -g ./cmd/server/main.go
11 changes: 3 additions & 8 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.6/.schema/devbox.schema.json",
"packages": [
"[email protected]",
"postgresql@latest"
],
"packages": ["[email protected]", "postgresql@latest", "go-swag@latest"],
"env": {
"ALLOWED_ORIGINS": "*",
"DB_HOST": "localhost",
"DB_HOST": "localhost",
"DB_PORT": "25432",
"DB_PORT_TEST": "35432",
"DB_USER": "postgres",
Expand All @@ -16,9 +13,7 @@
},
"shell": {
"scripts": {
"test": [
"echo \"Error: no test specified\" && exit 1"
],
"test": ["echo \"Error: no test specified\" && exit 1"],
"clean-db": [
"echo 'Removing PostgreSQL databases...'",
"rm -rf ./data/dev/*",
Expand Down
48 changes: 48 additions & 0 deletions devbox.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
{
"lockfile_version": "1",
"packages": {
"go-swag@latest": {
"last_modified": "2024-10-20T12:41:22Z",
"resolved": "github:NixOS/nixpkgs/ca30f584e18024baf39c395001262ed936f27ebd#go-swag",
"source": "devbox-search",
"version": "1.16.4",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/6injiyldyzxfma8fn4cr9m6kk1d4wzgc-go-swag-1.16.4",
"default": true
}
],
"store_path": "/nix/store/6injiyldyzxfma8fn4cr9m6kk1d4wzgc-go-swag-1.16.4"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/x9cxjc66kbyxyhps5d8im20ryh8x0w4c-go-swag-1.16.4",
"default": true
}
],
"store_path": "/nix/store/x9cxjc66kbyxyhps5d8im20ryh8x0w4c-go-swag-1.16.4"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/mqq20s7w8vsq8a04lch5sbzlck1bx1a0-go-swag-1.16.4",
"default": true
}
],
"store_path": "/nix/store/mqq20s7w8vsq8a04lch5sbzlck1bx1a0-go-swag-1.16.4"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/vlib2003m3vl5lb68ngvw8ncw32s2hbj-go-swag-1.16.4",
"default": true
}
],
"store_path": "/nix/store/vlib2003m3vl5lb68ngvw8ncw32s2hbj-go-swag-1.16.4"
}
}
},
"[email protected]": {
"last_modified": "2024-10-13T23:44:06Z",
"resolved": "github:NixOS/nixpkgs/d4f247e89f6e10120f911e2e2d2254a050d0f732#go",
Expand Down
205 changes: 205 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs

import "github.com/swaggo/swag"

const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/oracle/circulated-icy": {
"get": {
"description": "Get Circulated ICY",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Oracle"
],
"summary": "Get Circulated ICY",
"operationId": "getCirculatedICY",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_dwarvesf_icy-backend_internal_model.Web3BigInt"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
}
}
},
"/oracle/icy-btc-ratio": {
"get": {
"description": "Get ICY/BTC Realtime Price",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Oracle"
],
"summary": "Get ICY/BTC Realtime Price",
"operationId": "getICYBTCRatio",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_dwarvesf_icy-backend_internal_model.Web3BigInt"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
}
}
},
"/oracle/icy-btc-ratio-cached": {
"get": {
"description": "Get ICY/BTC cached Price",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Oracle"
],
"summary": "Get ICY/BTC cached Price",
"operationId": "getICYBTCRatioCached",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_dwarvesf_icy-backend_internal_model.Web3BigInt"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
}
}
},
"/oracle/treasury-btc": {
"get": {
"description": "Get Treasury BTC",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Oracle"
],
"summary": "Get Treasury BTC",
"operationId": "getTreasuryBTC",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_dwarvesf_icy-backend_internal_model.Web3BigInt"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
}
}
}
},
"definitions": {
"ApiError": {
"description": "validation error details",
"type": "object",
"properties": {
"enums": {
"description": "available options incase of field's payload is enums",
"type": "array",
"items": {
"type": "string"
}
},
"field": {
"description": "the field cause the error",
"type": "string"
},
"msg": {
"description": "error message",
"type": "string"
}
}
},
"ErrorResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"errors": {
"type": "array",
"items": {
"$ref": "#/definitions/ApiError"
}
}
}
},
"github_com_dwarvesf_icy-backend_internal_model.Web3BigInt": {
"type": "object",
"properties": {
"decimal": {
"type": "integer"
},
"value": {
"type": "string"
}
}
}
}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "",
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
Loading

0 comments on commit 64c7643

Please sign in to comment.