Skip to content

Commit

Permalink
Merge pull request #2 from AAStarCommunity/chao/account-to-node
Browse files Browse the repository at this point in the history
Chao/account to node
  • Loading branch information
fanhousanbu authored Apr 21, 2024
2 parents 528f011 + ddeccfd commit 130ad48
Show file tree
Hide file tree
Showing 18 changed files with 486 additions and 43 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,31 @@

A decentration community node for AirAccount

## What's Community Node
## What's Community Node

> TBD
## Quick Start

### 1. Swagger

#### 1.1 install

```shell
go get -u github.com/swaggo/swag
```

#### 1.2 init swag

```shell
swag init -g ./main.go
```

> FAQ: [Unknown LeftDelim and RightDelim in swag.Spec](https://github.com/swaggo/swag/issues/1568)
### 2. Run

```shell
go mod tidy
go run ./cmd/server/main.go
```
2 changes: 1 addition & 1 deletion conf/appsettings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jwt:
realm: AASTAR
idkey: id
node:
genesis: false
genesis: true
globalName: genesis-01
externalAddr: 0.0.0.0
externalPort: 7946
Expand Down
131 changes: 131 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// 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": {
"name": "AAStar Support",
"url": "https://aastar.xyz"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/account/v1/bind": {
"post": {
"security": [
{
"JWT": []
}
],
"description": "bind a account to community node",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Account"
],
"parameters": [
{
"description": "Account Binding",
"name": "bind",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.Bind"
}
}
],
"responses": {
"201": {
"description": "Created"
}
}
}
},
"/api/auth/v1/login": {
"post": {
"description": "Get AccessToken By ApiKey",
"consumes": [
"application/json"
],
"tags": [
"Auth"
],
"parameters": [
{
"description": "AccessToken Model",
"name": "credential",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.ClientCredential"
}
}
],
"responses": {
"201": {
"description": "Created"
}
}
}
}
},
"definitions": {
"request.Bind": {
"type": "object",
"properties": {
"account": {
"type": "string"
},
"publicKey": {
"type": "string"
}
}
},
"request.ClientCredential": {
"type": "object",
"properties": {
"apiKey": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"JWT": {
"description": "Type 'Bearer \\\u003cTOKEN\\\u003e' to correctly set the AccessToken",
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}`

// 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)
}
102 changes: 102 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"swagger": "2.0",
"info": {
"contact": {
"name": "AAStar Support",
"url": "https://aastar.xyz"
}
},
"paths": {
"/api/account/v1/bind": {
"post": {
"security": [
{
"JWT": []
}
],
"description": "bind a account to community node",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Account"
],
"parameters": [
{
"description": "Account Binding",
"name": "bind",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.Bind"
}
}
],
"responses": {
"201": {
"description": "Created"
}
}
}
},
"/api/auth/v1/login": {
"post": {
"description": "Get AccessToken By ApiKey",
"consumes": [
"application/json"
],
"tags": [
"Auth"
],
"parameters": [
{
"description": "AccessToken Model",
"name": "credential",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.ClientCredential"
}
}
],
"responses": {
"201": {
"description": "Created"
}
}
}
}
},
"definitions": {
"request.Bind": {
"type": "object",
"properties": {
"account": {
"type": "string"
},
"publicKey": {
"type": "string"
}
}
},
"request.ClientCredential": {
"type": "object",
"properties": {
"apiKey": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"JWT": {
"description": "Type 'Bearer \\\u003cTOKEN\\\u003e' to correctly set the AccessToken",
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}
63 changes: 63 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
definitions:
request.Bind:
properties:
account:
type: string
publicKey:
type: string
type: object
request.ClientCredential:
properties:
apiKey:
type: string
type: object
info:
contact:
name: AAStar Support
url: https://aastar.xyz
paths:
/api/account/v1/bind:
post:
consumes:
- application/json
description: bind a account to community node
parameters:
- description: Account Binding
in: body
name: bind
required: true
schema:
$ref: '#/definitions/request.Bind'
produces:
- application/json
responses:
"201":
description: Created
security:
- JWT: []
tags:
- Account
/api/auth/v1/login:
post:
consumes:
- application/json
description: Get AccessToken By ApiKey
parameters:
- description: AccessToken Model
in: body
name: credential
required: true
schema:
$ref: '#/definitions/request.ClientCredential'
responses:
"201":
description: Created
tags:
- Auth
securityDefinitions:
JWT:
description: Type 'Bearer \<TOKEN\>' to correctly set the AccessToken
in: header
name: Authorization
type: apiKey
swagger: "2.0"
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ require (
github.com/gin-gonic/gin v1.9.1
github.com/hashicorp/memberlist v0.5.1
github.com/stretchr/testify v1.9.0
github.com/swaggo/swag v1.8.12
github.com/swaggo/swag v1.16.3
gopkg.in/yaml.v2 v2.4.0
gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/purell v1.2.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
Expand All @@ -41,7 +41,7 @@ require (
github.com/miekg/dns v1.1.26 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools v0.20.0 // indirect
)

require (
Expand All @@ -68,9 +68,9 @@ require (
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 130ad48

Please sign in to comment.