Compare commits
5 Commits
924f76a100
...
1dfd96869d
Author | SHA1 | Date | |
---|---|---|---|
1dfd96869d | |||
a1ba28cacb | |||
d2bace87af | |||
9d507b9572 | |||
e89c17806f |
46
.air.linux.toml
Normal file
46
.air.linux.toml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
root = "."
|
||||||
|
testdata_dir = "testdata"
|
||||||
|
tmp_dir = "tmp"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
args_bin = []
|
||||||
|
bin = "tmp\\main"
|
||||||
|
cmd = "go build -o ./tmp/main ."
|
||||||
|
delay = 1000
|
||||||
|
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
|
||||||
|
exclude_file = []
|
||||||
|
exclude_regex = ["_test.go"]
|
||||||
|
exclude_unchanged = false
|
||||||
|
follow_symlink = false
|
||||||
|
full_bin = ""
|
||||||
|
include_dir = []
|
||||||
|
include_ext = ["go", "tpl", "tmpl", "html"]
|
||||||
|
include_file = []
|
||||||
|
kill_delay = "0s"
|
||||||
|
log = "build-errors.log"
|
||||||
|
poll = false
|
||||||
|
poll_interval = 0
|
||||||
|
post_cmd = []
|
||||||
|
pre_cmd = []
|
||||||
|
rerun = false
|
||||||
|
rerun_delay = 500
|
||||||
|
send_interrupt = false
|
||||||
|
stop_on_error = false
|
||||||
|
|
||||||
|
[color]
|
||||||
|
app = ""
|
||||||
|
build = "yellow"
|
||||||
|
main = "magenta"
|
||||||
|
runner = "green"
|
||||||
|
watcher = "cyan"
|
||||||
|
|
||||||
|
[log]
|
||||||
|
main_only = false
|
||||||
|
time = false
|
||||||
|
|
||||||
|
[misc]
|
||||||
|
clean_on_exit = false
|
||||||
|
|
||||||
|
[screen]
|
||||||
|
clear_on_rebuild = false
|
||||||
|
keep_scroll = true
|
@ -1,3 +1,3 @@
|
|||||||
tmp
|
tmp
|
||||||
docker-compose.yaml
|
docker-compose.yaml
|
||||||
.air.toml
|
.air*.toml
|
18
.woodpecker/build.yml
Normal file
18
.woodpecker/build.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
steps:
|
||||||
|
- name: build latest
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
settings:
|
||||||
|
repo: registry.odit.services/lfk/document-server
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
registry: registry.odit.services
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
cache_from: registry.odit.services/lfk/document-server:latest
|
||||||
|
username:
|
||||||
|
from_secret: odit-registry-builder-username
|
||||||
|
password:
|
||||||
|
from_secret: odit-registry-builder-password
|
||||||
|
when:
|
||||||
|
branch: main
|
||||||
|
when:
|
||||||
|
event: push
|
17
.woodpecker/release.yml
Normal file
17
.woodpecker/release.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
steps:
|
||||||
|
- name: build tag
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
settings:
|
||||||
|
repo: registry.odit.services/lfk/document-server
|
||||||
|
tags:
|
||||||
|
- "${CI_COMMIT_TAG}"
|
||||||
|
registry: registry.odit.services
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
cache_from: registry.odit.services/lfk/document-server:latest
|
||||||
|
username:
|
||||||
|
from_secret: odit-registry-builder-username
|
||||||
|
password:
|
||||||
|
from_secret: odit-registry-builder-password
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- tag
|
47
README.md
47
README.md
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- 📝 HTML pdf templates
|
- 📝 HTML templates for pdf generation
|
||||||
- 📚 OpenAPI/Swagger documentation
|
- 📚 OpenAPI/Swagger documentation
|
||||||
- ⚡ High-performance with go and gotenberg
|
- ⚡ High-performance with go and gotenberg
|
||||||
|
|
||||||
@ -12,9 +12,6 @@
|
|||||||
# Install dependencies
|
# Install dependencies
|
||||||
go mod download
|
go mod download
|
||||||
|
|
||||||
# Generate the swagger docs
|
|
||||||
swag init
|
|
||||||
|
|
||||||
# Run the server
|
# Run the server
|
||||||
air
|
air
|
||||||
```
|
```
|
||||||
@ -29,3 +26,45 @@ The project uses:
|
|||||||
|
|
||||||
- 🏃♂️ go as the language and build tool
|
- 🏃♂️ go as the language and build tool
|
||||||
- 🌐 gofiber for the web framework
|
- 🌐 gofiber for the web framework
|
||||||
|
- 📦 air for live reload
|
||||||
|
- 📝 swaggo for API documentation
|
||||||
|
- 📄 gotenberg for HTML to PDF conversion
|
||||||
|
|
||||||
|
### 📦 Use docker compose for external dependencies
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker compose -f docker-compose.dev.yaml up
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🏃 Run via air
|
||||||
|
|
||||||
|
> Install air via `go install github.com/air-verse/air@latest`
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# With the default air config
|
||||||
|
air
|
||||||
|
|
||||||
|
# With the config for linux/macOS
|
||||||
|
air -c .air.linux.toml
|
||||||
|
|
||||||
|
# With the config for windows
|
||||||
|
air -c .air.windows.toml
|
||||||
|
```
|
||||||
|
|
||||||
|
### ✒️ Update the swagger docs
|
||||||
|
|
||||||
|
> Install swag via `go install github.com/swaggo/swag/cmd/swag@latest`
|
||||||
|
|
||||||
|
```shell
|
||||||
|
swag init
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🐋 Build container
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# single arch
|
||||||
|
docker build -t registry.odit.services/lfk/document-server:latest .
|
||||||
|
|
||||||
|
# multiarch
|
||||||
|
docker buildx build --platform=linux/amd64,linux/arm64 -t registry.odit.services/lfk/document-server:latest --push .
|
||||||
|
```
|
||||||
|
14
docs/docs.go
14
docs/docs.go
@ -320,7 +320,19 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"securityDefinitions": {
|
||||||
|
"ApiKeyAuth": {
|
||||||
|
"type": "apiKey",
|
||||||
|
"name": "key",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"ApiKeyAuth": []
|
||||||
|
}
|
||||||
|
]
|
||||||
}`
|
}`
|
||||||
|
|
||||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||||
|
@ -311,5 +311,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"securityDefinitions": {
|
||||||
|
"ApiKeyAuth": {
|
||||||
|
"type": "apiKey",
|
||||||
|
"name": "key",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"ApiKeyAuth": []
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
@ -211,4 +211,11 @@ paths:
|
|||||||
summary: Generate a contract
|
summary: Generate a contract
|
||||||
tags:
|
tags:
|
||||||
- contracts
|
- contracts
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
securityDefinitions:
|
||||||
|
ApiKeyAuth:
|
||||||
|
in: query
|
||||||
|
name: key
|
||||||
|
type: apiKey
|
||||||
swagger: "2.0"
|
swagger: "2.0"
|
||||||
|
4
main.go
4
main.go
@ -57,6 +57,9 @@ func loadEnv() error {
|
|||||||
|
|
||||||
// @title LfK Document Server API
|
// @title LfK Document Server API
|
||||||
// @description This is the API documentation for the LfK Document Server - a tool for pdf generation.
|
// @description This is the API documentation for the LfK Document Server - a tool for pdf generation.
|
||||||
|
// @securityDefinitions.apiKey ApiKeyAuth
|
||||||
|
// @in query
|
||||||
|
// @name key
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
err := loadEnv()
|
err := loadEnv()
|
||||||
@ -76,6 +79,7 @@ func main() {
|
|||||||
// Swagger documentation route
|
// Swagger documentation route
|
||||||
app.Get("/swagger/*", swagger.HandlerDefault)
|
app.Get("/swagger/*", swagger.HandlerDefault)
|
||||||
|
|
||||||
|
// @Security ApiKeyAuth
|
||||||
v1 := app.Group("/v1")
|
v1 := app.Group("/v1")
|
||||||
v1.Use(keyauth.New(keyauth.Config{
|
v1.Use(keyauth.New(keyauth.Config{
|
||||||
KeyLookup: "query:key",
|
KeyLookup: "query:key",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user