prompt 10
This commit is contained in:
parent
e069100c53
commit
81245535b3
|
|
@ -9,6 +9,7 @@ APP_BUILD_HASH=dev
|
|||
DB_DRIVER=sqlite
|
||||
DB_SQLITE_PATH=data/app.sqlite3
|
||||
DB_POSTGRES_DSN=
|
||||
DB_PG_DSN=
|
||||
|
||||
# CORS (comma-separated)
|
||||
CORS_ORIGINS=http://localhost:3000
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
.PHONY: dev ui-build ui-dev test db-reset fmt
|
||||
|
||||
dev:
|
||||
go run ./cmd/server
|
||||
|
||||
ui-build:
|
||||
cd ui-kit && npm i && npm run build
|
||||
|
||||
ui-dev:
|
||||
cd ui-kit && npm i && npm run dev
|
||||
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
db-reset:
|
||||
rm -f ./data/app.db ./data/app.sqlite3
|
||||
|
||||
fmt:
|
||||
gofmt -w $$(find ./cmd ./internal -type f -name '*.go')
|
||||
112
README.md
112
README.md
|
|
@ -1,64 +1,72 @@
|
|||
# GoFiber MVC Boilerplate
|
||||
|
||||
Boilerplate riusabile per:
|
||||
Boilerplate GoFiber MVC + HTMX + Svelte Custom Elements + GORM, con auth server-rendered, area private/admin e mail sink in sviluppo.
|
||||
|
||||
- GoFiber (MVC)
|
||||
- HTMX
|
||||
- Svelte Custom Elements (UI kit)
|
||||
- GORM
|
||||
- SQLite/Postgres
|
||||
- Auth + ruolo `admin`
|
||||
- Email sink
|
||||
- CORS
|
||||
- Template directory `public` / `private` / `admin`
|
||||
|
||||
In ambiente `develop`, le email vengono salvate in `./data/emails` (sink locale).
|
||||
|
||||
## UI Kit (Vite + Svelte CE)
|
||||
|
||||
Comandi:
|
||||
## Quickstart SQLite
|
||||
|
||||
```bash
|
||||
cd ui-kit
|
||||
npm install
|
||||
npm run dev
|
||||
npm run build
|
||||
cp .env.example .env
|
||||
make dev
|
||||
```
|
||||
|
||||
La build scrive direttamente in `web/static/ui`:
|
||||
Default SQLite path: `./data/app.sqlite3`.
|
||||
|
||||
Comandi utili:
|
||||
|
||||
```bash
|
||||
make test
|
||||
make fmt
|
||||
make db-reset
|
||||
```
|
||||
|
||||
## Quickstart Postgres (Docker Compose)
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Configura `.env` così:
|
||||
|
||||
```env
|
||||
DB_DRIVER=postgres
|
||||
DB_PG_DSN=postgres://trustcontact:trustcontact@localhost:5432/trustcontact?sslmode=disable
|
||||
```
|
||||
|
||||
`DB_POSTGRES_DSN` è comunque supportato.
|
||||
|
||||
## UI Kit Build
|
||||
|
||||
```bash
|
||||
make ui-build
|
||||
```
|
||||
|
||||
Per sviluppo UI:
|
||||
|
||||
```bash
|
||||
make ui-dev
|
||||
```
|
||||
|
||||
Output build in `web/static/ui`:
|
||||
|
||||
- `ui.esm.js`
|
||||
- `ui.css`
|
||||
|
||||
## Struttura iniziale
|
||||
## Template Directories
|
||||
|
||||
```text
|
||||
.
|
||||
├── cmd/
|
||||
│ └── server/
|
||||
├── internal/
|
||||
│ ├── app/
|
||||
│ ├── auth/
|
||||
│ ├── config/
|
||||
│ ├── controllers/
|
||||
│ ├── db/
|
||||
│ ├── http/
|
||||
│ ├── mailer/
|
||||
│ ├── middleware/
|
||||
│ ├── models/
|
||||
│ ├── repo/
|
||||
│ └── services/
|
||||
├── ui-kit/
|
||||
├── web/
|
||||
│ ├── emails/
|
||||
│ │ └── templates/
|
||||
│ ├── static/
|
||||
│ │ ├── css/
|
||||
│ │ ├── ui/
|
||||
│ │ └── vendor/
|
||||
│ └── templates/
|
||||
│ ├── admin/
|
||||
│ ├── private/
|
||||
│ └── public/
|
||||
└── data/ # solo sviluppo locale
|
||||
```
|
||||
- Public: `web/templates/public`
|
||||
- Private: `web/templates/private`
|
||||
- Admin: `web/templates/admin`
|
||||
|
||||
## Email in Develop
|
||||
|
||||
In `develop`, le email vengono salvate in `./data/emails`.
|
||||
|
||||
## Make Targets
|
||||
|
||||
- `make dev` -> `go run ./cmd/server`
|
||||
- `make ui-build` -> install + build ui-kit
|
||||
- `make ui-dev` -> watch UI con Vite
|
||||
- `make test` -> `go test ./...`
|
||||
- `make db-reset` -> reset DB sqlite locale (`./data/app.db` / `./data/app.sqlite3`)
|
||||
- `make fmt` -> `gofmt` su `cmd/` e `internal/`
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
Aggiungi DX boilerplate.
|
||||
|
||||
- Makefile:
|
||||
- make dev (go run ./cmd/server)
|
||||
- make ui-build (cd ui-kit && npm i && npm run build)
|
||||
- make ui-dev (watch)
|
||||
- make test (go test ./...)
|
||||
- make db-reset (solo sqlite: rimuovi ./data/app.db)
|
||||
- make fmt (gofmt)
|
||||
|
||||
- docker-compose.yml:
|
||||
- postgres service (porta 5432)
|
||||
- env compatibile con DB_PG_DSN
|
||||
|
||||
- README.md:
|
||||
- Quickstart sqlite
|
||||
- Quickstart postgres (docker compose)
|
||||
- dove stanno templates public/private/admin
|
||||
- email in develop: ./data/emails
|
||||
- build UI kit
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
version: "3.9"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: trustcontact-postgres
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_USER: trustcontact
|
||||
POSTGRES_PASSWORD: trustcontact
|
||||
POSTGRES_DB: trustcontact
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
|
||||
# App env compatibility:
|
||||
# DB_DRIVER=postgres
|
||||
# DB_PG_DSN=postgres://trustcontact:trustcontact@localhost:5432/trustcontact?sslmode=disable
|
||||
# (also supported: DB_POSTGRES_DSN)
|
||||
|
|
@ -70,7 +70,7 @@ func Load() (*Config, error) {
|
|||
BuildHash: envOrDefault("APP_BUILD_HASH", "dev"),
|
||||
DBDriver: envOrDefault("DB_DRIVER", DBDriverSQLite),
|
||||
SQLitePath: envOrDefault("DB_SQLITE_PATH", "data/app.sqlite3"),
|
||||
PostgresDSN: strings.TrimSpace(os.Getenv("DB_POSTGRES_DSN")),
|
||||
PostgresDSN: envFirstNonEmpty("DB_POSTGRES_DSN", "DB_PG_DSN"),
|
||||
CORS: CORSConfig{
|
||||
Origins: envListOrDefault("CORS_ORIGINS", []string{"http://localhost:3000"}),
|
||||
Headers: envListOrDefault("CORS_HEADERS", []string{"Origin", "Content-Type", "Accept", "Authorization", "HX-Request"}),
|
||||
|
|
@ -202,3 +202,13 @@ func envListOrDefault(key string, fallback []string) []string {
|
|||
|
||||
return out
|
||||
}
|
||||
|
||||
func envFirstNonEmpty(keys ...string) string {
|
||||
for _, key := range keys {
|
||||
value := strings.TrimSpace(os.Getenv(key))
|
||||
if value != "" {
|
||||
return value
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue