Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ DB_PATH=./data/formera.db
JWT_SECRET=your-secure-secret-here # CHANGE IN PRODUCTION!
#CORS_ORIGIN=http://localhost:3000 # Optional: Only set if frontend is on different domain

# =============================================================================
# PROXY / RATE LIMITING
# =============================================================================
# Trusted proxies for accurate client IP detection (comma-separated IPs/CIDRs)
# Leave empty to trust all proxies (default, for development)
# Examples: "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16" for private networks
#TRUSTED_PROXIES=

# Custom header for client IP (overrides default X-Forwarded-For / X-Real-IP)
# Common values: CF-Connecting-IP (Cloudflare), X-Real-IP (Nginx), True-Client-IP
#REAL_IP_HEADER=

# =============================================================================
# STORAGE
# =============================================================================
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: API Documentation

on:
push:
branches:
- main
paths:
- 'backend/**'
- 'api-docs/**'
- '.github/workflows/docs.yml'

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
name: Generate Swagger Docs
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Install swag
run: go install github.com/swaggo/swag/cmd/swag@latest

- name: Generate Swagger documentation
run: swag init -g cmd/server/main.go -o docs --parseInternal --parseDependency
working-directory: backend

- name: Copy docs to api-docs
run: cp backend/docs/swagger.json api-docs/

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'api-docs'

deploy:
name: Deploy to GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
55 changes: 55 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
stages:
- build
- docs
- deploy

variables:
GO_VERSION: "1.23"

# Generate Swagger documentation
swagger:
stage: docs
image: golang:${GO_VERSION}
script:
- go install github.com/swaggo/swag/cmd/swag@latest
- cd backend
- swag init -g cmd/server/main.go -o docs --parseInternal --parseDependency
- cp docs/swagger.json ../api-docs/
artifacts:
paths:
- api-docs/
expire_in: 1 week
only:
- main
- develop
- merge_requests

# Deploy API documentation to GitLab Pages
pages:
stage: deploy
dependencies:
- swagger
script:
- mkdir -p public
- cp -r api-docs/* public/
artifacts:
paths:
- public
only:
- main
environment:
name: documentation
url: https://$CI_PROJECT_NAMESPACE.gitlab.io/$CI_PROJECT_NAME

# Optional: Build backend to verify code compiles
build:backend:
stage: build
image: golang:${GO_VERSION}
script:
- cd backend
- go mod download
- go build -v ./...
only:
- main
- develop
- merge_requests
58 changes: 58 additions & 0 deletions api-docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Formera API Documentation</title>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css">
<style>
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #fafafa;
}
.swagger-ui .topbar {
background-color: #2563eb;
}
.swagger-ui .topbar .download-url-wrapper .select-label {
color: white;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js" charset="UTF-8"></script>
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-standalone-preset.js" charset="UTF-8"></script>
<script>
window.onload = function() {
const ui = SwaggerUIBundle({
url: "./swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
persistAuthorization: true,
displayRequestDuration: true,
filter: true,
tryItOutEnabled: true
});
window.ui = ui;
};
</script>
</body>
</html>
Loading
Loading