Merge branch 'feature/08-authorize-user'

This commit is contained in:
2026-06-22 13:21:34 +02:00
5 changed files with 36 additions and 39 deletions
+1
View File
@@ -1,5 +1,6 @@
# -include: silently skip if .env doesn't exist (e.g. fresh clone before 'cp .env.example .env')
-include .env
-include backend/.env
export
.PHONY: dev-db migrate-up migrate-down run-backend run-frontend test fmt
+31 -1
View File
@@ -17,13 +17,43 @@ A full-stack fruit-variety database (Go + Vue 3).
cp .env.example .env # set credentials
cp backend/.env.example backend/.env # set JWT_SECRET and USERS_FILE
cp users.env.example users.env # create user file (see below)
./scripts/create_user.sh admin secret >> users.env # add a user
./scripts/create_user.sh admin secret >> users.env # add a user (restart backend to reload)
make dev-db # start Postgres (waits until healthy)
make migrate-up # apply schema migrations
make run-backend # Echo API on :3000
make run-frontend # Vite dev server on :5000
```
## Importing Legacy Data
Prerequisites: Postgres running and migrated, `psycopg2` installed (`pip install psycopg2-binary`), `03-data/` present at repo root.
Scripts must be run in order — publications depend on fruits being present.
### 1. Import fruits
```bash
DATABASE_URL=postgres://osdb:osdb@localhost:5432/osdb?sslmode=disable python3 scripts/import_fruits.py
```
Imports fruits, synonyms, and fruit images from `03-data/obstsorten.xml`. Idempotent: upserts by `osdb_number`.
### 2. Import publications
```bash
DATABASE_URL=postgres://osdb:osdb@localhost:5432/osdb?sslmode=disable python3 scripts/import_publications.py
```
Imports publications from `03-data/osws.xml`. For each publication: upserts the row, loads cover image, links fruits, and imports PDFs and fruit images. Idempotent: clears and re-inserts linked data on re-run.
## Managing Users
Add a user and restart the backend to reload:
```bash
./scripts/create_user.sh <username> <password> >> users.env
```
## Testing
```bash
+1 -1
View File
@@ -1,4 +1,4 @@
DATABASE_URL=postgres://osdb:osdb@localhost:5432/osdb
DATABASE_URL=postgres://osdb:osdb@localhost:5432/osdb?sslmode=disable
PORT=3000
JWT_SECRET=change-me-use-a-long-random-string
USERS_FILE=../users.env
-37
View File
@@ -1,37 +0,0 @@
# Import Scripts
## Prerequisites
- Postgres running and migrated (`make migrate-up`)
- `DATABASE_URL` set, e.g.:
```
export DATABASE_URL=postgres://user:pass@localhost:5432/osdb
```
- `03-data/` directory present at repo root
- `psycopg2` installed (`pip install psycopg2-binary`)
---
## Run Order
Scripts must be run in order — publications import depends on fruits being present.
### 1. Import fruits
```bash
DATABASE_URL=... python3 scripts/import_fruits.py
```
Imports fruits, synonyms, and fruit images from `03-data/obstsorten.xml`.
Idempotent: upserts fruits by `osdb_number`.
### 2. Import publications
```bash
DATABASE_URL=... python3 scripts/import_publications.py
```
Imports publications from `03-data/osws.xml` (only `<obj>` elements with `<osw>=1`).
For each publication: upserts the row, loads cover image, links fruits found by
filesystem scan of `03-data/osdb/{pubId}/`, and imports PDFs and fruit images.
Idempotent: clears and re-inserts linked data on re-run.
+3
View File
@@ -51,7 +51,10 @@ TYP_MAP = {
IMAGE_DIRS = [
("einzelfruechte", "fruit"),
("osdb/fru", "fruit"),
("osdb/frucht", "fruit"),
("blueten", "flower"),
("osdb/blu", "flower"),
("baume", "tree"),
]