Skip to content

Commit

Permalink
update: init project
Browse files Browse the repository at this point in the history
  • Loading branch information
asjdf committed Oct 28, 2023
0 parents commit b515043
Show file tree
Hide file tree
Showing 29 changed files with 3,724 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
on: # Apply to all pushes to `main`
pull_request:
push:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
with:
github_token: ${{ github.token }}
- uses: bufbuild/[email protected]
with:
buf_token: ${{ secrets.BUF_TOKEN }}
breaking:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
with:
github_token: ${{ github.token }}
- uses: bufbuild/[email protected]
with:
against: 'https://github.com/juanjiTech/daya-proto.git#branch=main'
buf_token: ${{ secrets.BUF_TOKEN }}
generate:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- lint
- breaking
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- run: go install github.com/grpc-ecosystem/protoc-gen-grpc-gateway-ts
- uses: bufbuild/[email protected]
with:
github_token: ${{ github.token }}
- run: rm -rf ./gen && buf generate && go mod tidy
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'update: automatic generate new proto'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# daya-proto

## 快速开始

1. 安装软件
- [buf](https://buf.build/docs/installation) 以及buf的IDE插件
- `go install github.com/grpc-ecosystem/protoc-gen-grpc-gateway-ts`
- `buf mod update`
2. 修改proto
3. 检查 `buf lint`
4. 生成 `buf generate`

## 相关文档

[OpenAPI 说明](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/customizing_openapi_output/)
21 changes: 21 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# command: buf generate
version: v1
plugins:
- plugin: buf.build/protocolbuffers/go
out: gen/proto
opt:
- paths=source_relative
- plugin: buf.build/grpc/go
out: gen/proto
opt:
- paths=source_relative
- plugin: buf.build/grpc-ecosystem/gateway
out: gen/proto
opt:
- paths=source_relative
- plugin: buf.build/grpc-ecosystem/openapiv2
out: gen/openapi
- name: grpc-gateway-ts
out: gen/proto
opt:
- paths=source_relative
8 changes: 8 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
3 changes: 3 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1
directories:
- proto
9 changes: 9 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
deps:
- buf.build/googleapis/googleapis
219 changes: 219 additions & 0 deletions gen/openapi/auth/v1/auth_service.swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
{
"swagger": "2.0",
"info": {
"title": "auth/v1/auth_service.proto",
"version": "version not set"
},
"tags": [
{
"name": "AuthService"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/gapi/auth/v1/login": {
"post": {
"summary": "用户登录",
"operationId": "AuthService_Login",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1LoginResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1LoginRequest"
}
}
],
"tags": [
"AuthService"
]
}
},
"/gapi/auth/v1/refreshToken": {
"post": {
"summary": "Token刷新",
"operationId": "AuthService_RefreshToken",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1RefreshTokenResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1RefreshTokenRequest"
}
}
],
"tags": [
"AuthService"
]
}
},
"/gapi/auth/v1/register": {
"post": {
"summary": "用户注册",
"operationId": "AuthService_Register",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1RegisterResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1RegisterRequest"
}
}
],
"tags": [
"AuthService"
]
}
}
},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
},
"v1LoginRequest": {
"type": "object",
"properties": {
"username": {
"type": "string",
"title": "账户 可为手机号或邮箱"
},
"password": {
"type": "string"
},
"twoFactorAuth": {
"type": "string"
}
}
},
"v1LoginResponse": {
"type": "object",
"properties": {
"accessToken": {
"type": "string"
},
"refreshToken": {
"type": "string"
}
}
},
"v1RefreshTokenRequest": {
"type": "object",
"properties": {
"refreshToken": {
"type": "string"
}
}
},
"v1RefreshTokenResponse": {
"type": "object",
"properties": {
"accessToken": {
"type": "string"
},
"refreshToken": {
"type": "string"
}
}
},
"v1RegisterRequest": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"verifyCode": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
"v1RegisterResponse": {
"type": "object",
"properties": {
"accessToken": {
"type": "string"
},
"refreshToken": {
"type": "string"
}
}
}
}
}
44 changes: 44 additions & 0 deletions gen/openapi/user/v1/user.swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"swagger": "2.0",
"info": {
"title": "user/v1/user.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}
Loading

0 comments on commit b515043

Please sign in to comment.