-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Monolithic Application example, including frontend and back…
…end.
- Loading branch information
Showing
871 changed files
with
137,563 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
# examples | ||
# Kratos examples | ||
|
||
English | [简体中文](README-CN.md) | ||
|
||
- blog is simple crud project. | ||
- config is kratos config example. | ||
- errors is kratos errors example, it is generated through proto-gen-go-errors. | ||
- helloworld is helloworld example. | ||
- http is transport/http some examples of usage. | ||
- log is log example, including、logger、helper、filter、valuer, etc. | ||
- metadata is metadata example. | ||
- metrics is metrics example, in the example, prom is used to collect data. | ||
- registry is registration and discovery examples,including Etcd, Consul, Nacos. | ||
- traces is middleware/tracing example,middleware/tracing is implemented by opentelemetry. | ||
- validate is middleware/validate example, the verification code is generated by proto-gen-validate. | ||
- ws is implementation of transport interface with websocket example. | ||
- swagger is implementation of server with embed swagger api. | ||
| Project Name | Description | | ||
| ---------------------------- | ----------------------------------------------------------------------- | | ||
| [auth/jwt](./auth/jwt) | Examples of JWT usage | | ||
| [blog](./blog) | Blog system, simple CRUD example | | ||
| [casbin](./casbin) | Examples of JWT authentication and Casbin authentication | | ||
| [chatroom](./chatroom) | The simplest Websocket chat room example | | ||
| [config](./config) | Examples of file configuration and remote configuration Center usage | | ||
| [cqrs](./cqrs) | Examples of CQRS pattern implementation, mainly the use of Kafka. | | ||
| [errors](./errors) | Error handling example | | ||
| [event](./event) | Example of sending and receiving messages using MQ like Kafka | | ||
| [header](./header) | Example of a custom HTTP Header | | ||
| [helloworld](./helloworld) | RPC Call example | | ||
| [http](./http) | Examples of HTTP-related applications, such as CORS and uploading files | | ||
| [i18n](./i18n) | Examples of internationalization and localization | | ||
| [log](./log) | Log usage example | | ||
| [metadata](./metadata) | Examples of metadata usage | | ||
| [metrics](./metrics) | Measurement system usage examples | | ||
| [middleware](./middleware) | Middleware usage Examples | | ||
| [realtimemap](./realtimemap) | Real-time bus map, mainly MQTT, Websocket, RPC integrated use | | ||
| [registry](./registry) | Registry center usage examples | | ||
| [selector](./selector) | Examples of node selector usage | | ||
| [stream](./stream) | | | ||
| [swagger](./swagger) | swagger is implementation of server with embed swagger api | | ||
| [tls](./tls) | Example of TLS certificate usage | | ||
| [traces](./traces) | Example of Distributed Tracing system | | ||
| [transaction](./transaction) | Sample database transaction usage | | ||
| [validate](./validate) | Example of Protobuf parameter validator usage | | ||
| [ws](./ws) | ws is implementation of transport interface with websocket example | | ||
| [monolithic](./monolithic) | Monolithic Application example, including frontend and backends. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Bobo | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Golang微服务框架Kratos的巨石应用实践 | ||
|
||
- 后端基于 golang微服务框架 [go-kratos](https://go-kratos.dev/) | ||
- 前端基于 [VUE3](https://vuejs.org/) + [TypeScript](https://www.typescriptlang.org/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Reference https://github.com/github/gitignore/blob/master/Go.gitignore | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
vendor/ | ||
|
||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
|
||
# OS General | ||
Thumbs.db | ||
.DS_Store | ||
|
||
# project | ||
*.cert | ||
*.key | ||
*.log | ||
bin/ | ||
|
||
# Develop tools | ||
.vscode/ | ||
.idea/ | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
line-length: false | ||
no-hard-tabs: false | ||
no-inline-html: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# vim: ft=yaml | ||
--- | ||
yaml-files: | ||
- "*.yaml" | ||
- "*.yml" | ||
- ".yamllint" | ||
extends: "default" | ||
rules: | ||
quoted-strings: "enable" | ||
line-length: "disable" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Not Support Windows | ||
|
||
.PHONY: help wire gen ent build api openapi init all | ||
|
||
ifeq ($(OS),Windows_NT) | ||
IS_WINDOWS:=1 | ||
endif | ||
|
||
CURRENT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))) | ||
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
SRCS_MK := $(foreach dir, app, $(wildcard $(dir)/*/*/Makefile)) | ||
|
||
# initialize develop environment | ||
init: plugin cli | ||
|
||
# install protoc plugin | ||
plugin: | ||
@go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | ||
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | ||
@go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest | ||
@go install github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@latest | ||
@go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest | ||
@go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest | ||
@go install github.com/envoyproxy/protoc-gen-validate@latest | ||
|
||
# install cli tools | ||
cli: | ||
@go install github.com/go-kratos/kratos/cmd/kratos/v2@latest | ||
@go install github.com/google/gnostic@latest | ||
@go install github.com/bufbuild/buf/cmd/buf@latest | ||
@go install entgo.io/ent/cmd/ent@latest | ||
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
|
||
# generate wire code | ||
wire: | ||
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\ | ||
cd $(dir);\ | ||
make wire;\ | ||
) | ||
|
||
# generate code by go:generate | ||
gen: | ||
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\ | ||
cd $(dir);\ | ||
make gen;\ | ||
) | ||
|
||
# generate ent code | ||
ent: | ||
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\ | ||
cd $(dir);\ | ||
make ent;\ | ||
) | ||
|
||
# generate protobuf api go code | ||
api: | ||
buf generate | ||
|
||
# generate OpenAPI v3 docs. | ||
openapi: | ||
buf generate --path api/admin/service/v1 --template api/admin/service/v1/buf.openapi.gen.yaml | ||
|
||
# build all service applications | ||
build: | ||
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\ | ||
cd $(dir);\ | ||
make build;\ | ||
) | ||
|
||
# generate & build all service applications | ||
all: | ||
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\ | ||
cd $(dir);\ | ||
make app;\ | ||
) | ||
|
||
# show help | ||
help: | ||
@echo "" | ||
@echo "Usage:" | ||
@echo " make [target]" | ||
@echo "" | ||
@echo 'Targets:' | ||
@awk '/^[a-zA-Z\-_0-9]+:/ { \ | ||
helpMessage = match(lastLine, /^# (.*)/); \ | ||
if (helpMessage) { \ | ||
helpCommand = substr($$1, 0, index($$1, ":")-1); \ | ||
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \ | ||
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \ | ||
} \ | ||
} \ | ||
{ lastLine = $$0 }' $(MAKEFILE_LIST) | ||
|
||
.DEFAULT_GOAL := help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# GO后端 | ||
|
||
## API文档 | ||
|
||
### Swagger UI | ||
|
||
- [Admin Swagger UI](http://localhost:7788/docs/) | ||
|
||
### openapi.yaml | ||
|
||
- [Admin openapi.yaml](http://localhost:7788/docs/openapi.yaml) | ||
|
||
## Buf.Build使用 | ||
|
||
使用[buf.build](https://buf.build/)进行Protobuf API的工程化构建。 | ||
|
||
相关命令行工具和插件的具体安装方法请参见:[Kratos微服务框架API工程化指南](https://juejin.cn/post/7191095845096259641) | ||
|
||
在`backend`根目录下执行命令: | ||
|
||
### 更新buf.lock | ||
|
||
```bash | ||
buf mod update | ||
``` | ||
|
||
### 生成GO代码 | ||
|
||
```bash | ||
buf generate | ||
``` | ||
|
||
### 生成OpenAPI v3文档 | ||
|
||
```bash | ||
buf generate --path api/admin/service/v1 --template api/admin/service/v1/buf.openapi.gen.yaml | ||
``` | ||
|
||
## Make构建 | ||
|
||
请在`app/{服务名}/service`下执行: | ||
|
||
### 初始化开发环境 | ||
|
||
```bash | ||
make init | ||
``` | ||
|
||
### 生成API的go代码 | ||
|
||
```bash | ||
make api | ||
``` | ||
|
||
### 生成API的OpenAPI v3 文档 | ||
|
||
```bash | ||
make openapi | ||
``` | ||
|
||
### 生成ent代码 | ||
|
||
```bash | ||
make ent | ||
``` | ||
|
||
### 生成wire代码 | ||
|
||
```bash | ||
make wire | ||
``` | ||
|
||
### 构建程序 | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
### 调试运行 | ||
|
||
```bash | ||
make run | ||
``` | ||
|
||
### 构建Docker镜像 | ||
|
||
```bash | ||
make docker | ||
``` |
Oops, something went wrong.