Scaffold app, chart, CI and release (26.11.1) #2

Merged
kai merged 1 commits from claude/ap1-geruest into main 2026-11-06 19:14:58 +00:00
52 changed files with 6474 additions and 3 deletions

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
node_modules
.next
.git
dist
test-results
docs
olares
tests
*.md
+107
View File
@@ -0,0 +1,107 @@
name: ci
on:
pull_request:
branches: [main]
# Nachts alles auf main. Gestaffelt mit den anderen Apps auf dem einen
# Runner (Relay 05:30, Rocket 06:00, Insilo 06:30 MESZ): Lunch 07:00 MESZ.
# Der Cron ist UTC.
schedule:
- cron: "0 5 * * *"
workflow_dispatch:
# Ein neuer Push in einen PR ersetzt seinen älteren Lauf.
concurrency:
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
chart:
name: olares chart · sanity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# get.helm.sh ist vom Gitea-Runner nicht erreichbar: Helm liegt als
# Release-Anhang in aimighty/ci-tools, get.helm.sh bleibt Rückfall.
- name: install helm 3.16.2
run: |
for url in \
"https://git.aimighty.olares.de/aimighty/ci-tools/releases/download/helm-3.16.2/helm-v3.16.2-linux-amd64.tar.gz" \
"https://get.helm.sh/helm-v3.16.2-linux-amd64.tar.gz"; do
echo "hole $url"
if curl -fsSL --retry 3 --retry-all-errors --max-time 180 -o /tmp/helm.tgz "$url" \
&& tar -tzf /tmp/helm.tgz >/dev/null 2>&1; then
break
fi
done
tar -C /tmp -xzf /tmp/helm.tgz
install -m 0755 /tmp/linux-amd64/helm /usr/local/bin/helm
helm version --short
- name: codified Olares lessons (scripts/check-chart.sh)
run: bash scripts/check-chart.sh
app:
name: app · types + tests + build
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
# Kein ports: — auf Gitea läuft der Job in einem Container neben dem
# Dienst und erreicht ihn über dessen Namen (Muster aimighty/rocket).
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- name: database host
run: |
if getent hosts postgres >/dev/null 2>&1; then H=postgres; else H=localhost; fi
echo "PGHOST=$H" >> "$GITHUB_ENV"
echo "DB_HOST=$H" >> "$GITHUB_ENV"
echo "TEST_DATABASE_URL=postgres://lunch:lunch_dev_only@$H/lunch" >> "$GITHUB_ENV"
echo "Datenbank unter $H"
- name: psql
run: |
command -v psql >/dev/null && { psql --version; exit 0; }
SUDO=""; [ "$(id -u)" != "0" ] && command -v sudo >/dev/null && SUDO="sudo"
$SUDO apt-get update -qq
$SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y -qq postgresql-client
psql --version
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- name: install
run: npm ci
- name: type-check
run: npm run type-check
# Wie auf der Box: Die Migrationen laufen mit der Rolle der App, die
# dadurch Eigentümerin der Tabellen wird — kein Superuser. Nur so prüft
# der Test mit zwei Haushalten, dass FORCE ROW LEVEL SECURITY greift.
- name: database and migrations
run: |
PGPASSWORD=postgres psql -U postgres -c "create role lunch login password 'lunch_dev_only';"
PGPASSWORD=postgres psql -U postgres -c "create database lunch owner lunch;"
DATABASE_URL="$TEST_DATABASE_URL" MIGRATE_ATTEMPTS=3 npm run migrate
# Ein zweiter Lauf darf nichts tun.
DATABASE_URL="$TEST_DATABASE_URL" MIGRATE_ATTEMPTS=3 npm run migrate
- name: unit and database tests
run: npm test
- name: build
run: npm run build
env:
NEXT_TELEMETRY_DISABLED: "1"
+276
View File
@@ -0,0 +1,276 @@
name: release
# Baut das Abbild und legt es unter
# git.aimighty.olares.de/aimighty/lunch-app:<version> ab (Gitea-Registry,
# Organisation aimighty, öffentlich: Die Box zieht ohne Anmeldung). Dazu das
# gepackte Chart als Anhang am Release — die Datei, die in den Markt geht.
# Vorbild: aimighty/rocket .github/workflows/release.yml.
#
# Auslöser:
# - **Merge nach main mit neuer Version** in olares/Chart.yaml: bauen, danach
# Tag `v<version>` samt Release über die Gitea-API — erst nach
# erfolgreichem Bau. Gibt es den Tag schon, passiert nichts.
# - **PR**, der Dockerfile, Abhängigkeiten oder diesen Workflow ändert: Chart
# prüfen und packen, Abbild bauen, nichts hochladen.
# - **Run workflow** mit Version: bauen und hochladen, ohne Tag.
#
# Kein Auslöser auf Tags: Tags setzt nur dieser Workflow selbst.
# Gitea-Besonderheiten: ein Runner; Helm aus aimighty/ci-tools; der
# Docker-Daemon sitzt hinter dem Bridge-Gateway; gebaut wird nur amd64.
on:
pull_request:
paths:
- Dockerfile
- package-lock.json
- .github/workflows/release.yml
push:
branches: [main]
# Auch der Workflow selbst: Wer ihn ändert, soll sehen, dass er läuft
# — und eine noch nicht getaggte Version wird dabei veröffentlicht.
paths: [olares/Chart.yaml, .github/workflows/release.yml]
workflow_dispatch:
inputs:
version:
description: "Image tag without leading v (e.g. 26.10.26); empty = olares/Chart.yaml"
required: false
# Die Probe eines PR: nur sein neuester Push zählt. Ein Release auf main
# bekommt eine eigene Gruppe (run_id) und wird nie abgebrochen (Kai,
# 14.10.2026).
concurrency:
group: release-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
version:
name: which version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.v.outputs.version }}
proceed: ${{ steps.v.outputs.proceed }}
push: ${{ steps.v.outputs.push }}
create_tag: ${{ steps.v.outputs.create_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # die Tags gehören zur Entscheidung
- id: v
run: |
CHART_VERSION="$(grep -E '^version:' olares/Chart.yaml | head -1 | awk '{print $2}' | tr -d '"')"
PROCEED=true; PUSH=true; CREATE=false
if [ "${{ github.event_name }}" = "pull_request" ]; then
V="$CHART_VERSION"; PUSH=false
echo "### PR: Chart $V prüfen und packen, Abbilder bauen ohne Hochladen" >> "$GITHUB_STEP_SUMMARY"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
V="${{ inputs.version }}"; [ -n "$V" ] || V="$CHART_VERSION"
else
V="$CHART_VERSION"
if git rev-parse -q --verify "refs/tags/v$V" >/dev/null; then
PROCEED=false
echo "### v$V ist schon getaggt — kein Release" >> "$GITHUB_STEP_SUMMARY"
else
CREATE=true
echo "### Neue Version $V — bauen, dann v$V taggen" >> "$GITHUB_STEP_SUMMARY"
fi
fi
echo "version=$V" >> "$GITHUB_OUTPUT"
echo "proceed=$PROCEED" >> "$GITHUB_OUTPUT"
echo "push=$PUSH" >> "$GITHUB_OUTPUT"
echo "create_tag=$CREATE" >> "$GITHUB_OUTPUT"
echo "version=$V proceed=$PROCEED push=$PUSH create_tag=$CREATE"
preflight:
name: olares chart · sanity
needs: version
if: needs.version.outputs.proceed == 'true'
runs-on: ubuntu-latest
outputs:
build_images: ${{ steps.decide.outputs.build_images }}
env:
VERSION: ${{ needs.version.outputs.version }}
steps:
- uses: actions/checkout@v4
# get.helm.sh ist vom Gitea-Runner nicht erreichbar: Helm liegt als
# Release-Anhang in aimighty/ci-tools, get.helm.sh bleibt Rückfall.
- name: install helm 3.16.2
run: |
for url in \
"https://git.aimighty.olares.de/aimighty/ci-tools/releases/download/helm-3.16.2/helm-v3.16.2-linux-amd64.tar.gz" \
"https://get.helm.sh/helm-v3.16.2-linux-amd64.tar.gz"; do
echo "hole $url"
if curl -fsSL --retry 3 --retry-all-errors --max-time 180 -o /tmp/helm.tgz "$url" \
&& tar -tzf /tmp/helm.tgz >/dev/null 2>&1; then
break
fi
done
tar -C /tmp -xzf /tmp/helm.tgz
install -m 0755 /tmp/linux-amd64/helm /usr/local/bin/helm
helm version --short
- name: codified Olares lessons (scripts/check-chart.sh)
run: bash scripts/check-chart.sh
- name: chart version must match the version to release
if: github.event_name == 'push'
run: |
CHART_VERSION="$(grep -E '^version:' olares/Chart.yaml | head -1 | awk '{print $2}' | tr -d '"')"
if [ "$VERSION" != "$CHART_VERSION" ]; then
echo "::error::version $VERSION does not match olares/Chart.yaml version $CHART_VERSION"
exit 1
fi
echo "version $VERSION matches the chart"
# Ein leerer Tag in values.yaml heißt „folgt Chart.AppVersion" — der
# Normalfall, das Chart referenziert dann genau diesen Tag. Ein
# gesetzter Tag ist ein Pin auf eine Vorversion: Die Abbilder gibt es
# schon, nichts bauen.
- name: are images needed for this version?
id: decide
run: |
BUILD=true
PINS="$(grep -E "^[[:space:]]+tag:" olares/values.yaml | grep -vE 'tag:[[:space:]]*(""|'"''"')[[:space:]]*$' || true)"
if [ -n "$PINS" ] \
&& ! grep -qE "^[[:space:]]+tag:[[:space:]]*[\"']?${VERSION}[\"']?[[:space:]]*$" olares/values.yaml; then
BUILD=false
fi
echo "build_images=$BUILD" >> "$GITHUB_OUTPUT"
if [ "$BUILD" = "true" ]; then
echo "### Abbilder werden gebaut ($VERSION)" >> "$GITHUB_STEP_SUMMARY"
else
echo "### Abbild-Bau übersprungen — values.yaml pinnt eine Vorversion" >> "$GITHUB_STEP_SUMMARY"
fi
- name: package chart
run: |
mkdir -p dist
helm package olares -d dist
ls -la dist
- uses: actions/upload-artifact@v4
with:
name: chart
path: dist/*.tgz
if-no-files-found: error
build:
name: ${{ matrix.service }}
needs: [version, preflight]
if: needs.preflight.outputs.build_images == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
fail-fast: false
# Ein Runner, ein Daemon: nacheinander.
max-parallel: 1
matrix:
include:
- service: app
context: .
dockerfile: ./Dockerfile
steps:
- uses: actions/checkout@v4
# Der Docker-Daemon des Runners ist ein dind-InitContainer im
# Runner-Pod (privileged, :2375). Aus dem Job-Container erreicht man
# weder den Socket noch 127.0.0.1, nur das Bridge-Gateway des
# Job-Netzes (aimighty/insilo UEBERGABE.md). `ip` fehlt im
# act-Container: das Gateway steht in /proc/net/route.
- name: find the runner's Docker daemon (dind at the bridge gateway)
run: |
read -r _ dest gw _ < <(awk '$2=="00000000" {print; exit}' /proc/net/route)
GW="$(printf "%d.%d.%d.%d" 0x${gw:6:2} 0x${gw:4:2} 0x${gw:2:2} 0x${gw:0:2})"
ok=0
for KANDIDAT in "$GW" "172.17.0.1"; do
[ -n "$KANDIDAT" ] || continue
if DOCKER_HOST="tcp://$KANDIDAT:2375" docker version >/dev/null 2>&1; then
echo "DOCKER_HOST=tcp://$KANDIDAT:2375" >> "$GITHUB_ENV"
echo "Daemon erreichbar unter tcp://$KANDIDAT:2375"
ok=1
break
fi
done
[ "$ok" = "1" ] || { echo "::error::kein Docker-Daemon am Bridge-Gateway gefunden"; exit 1; }
- uses: docker/setup-buildx-action@v3
# REGISTRY_TOKEN (Organisations-Geheimnis in aimighty): ein Gitea-Token
# mit package Lesen und Schreiben eines Kontos, das in der Organisation
# Pakete anlegen darf.
- name: Log in to the Gitea registry
if: needs.version.outputs.push == 'true'
uses: docker/login-action@v3
with:
registry: git.aimighty.olares.de
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
# Nur amd64 — das Manifest verspricht auch nur das. Ein Next.js-Bau
# unter QEMU für arm64 dauert eine halbe Stunde, und keine Box, die
# diese App bekommt, ist eine ARM-Maschine.
- name: Build (and push)
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
platforms: linux/amd64
push: ${{ needs.version.outputs.push == 'true' }}
tags: |
git.aimighty.olares.de/aimighty/lunch-${{ matrix.service }}:${{ needs.version.outputs.version }}
git.aimighty.olares.de/aimighty/lunch-${{ matrix.service }}:latest
# Erst wenn das Abbild draußen ist: Tag und Release, mit dem Chart
# als Anhang — dieselbe Datei, die in den Markt geht.
release:
name: tag and release
needs: [version, preflight, build]
# Gitea meldet einen übersprungenen Job nicht verlässlich als „skipped":
# laufen, sobald ein Tag fällig ist, und das Ergebnis selbst prüfen.
if: always() && needs.version.outputs.create_tag == 'true'
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.version.outputs.version }}
GITEA_API: https://git.aimighty.olares.de/api/v1
steps:
- name: chart and images ready?
env:
PREFLIGHT: ${{ needs.preflight.result }}
BUILD: ${{ needs.build.result }}
BUILD_IMAGES: ${{ needs.preflight.outputs.build_images }}
run: |
echo "preflight '$PREFLIGHT', build '$BUILD', build_images '$BUILD_IMAGES'"
[ "$PREFLIGHT" = "success" ] || { echo "::error::Chart nicht geprüft ($PREFLIGHT) — kein Tag, kein Release"; exit 1; }
if [ "$BUILD_IMAGES" = "true" ]; then
[ "$BUILD" = "success" ] || { echo "::error::Abbilder nicht gebaut ($BUILD) — kein Tag, kein Release"; exit 1; }
else
# Release nur mit Chart: ein absichtlich übersprungener Bau ist in
# Ordnung, ein gescheiterter oder abgebrochener nicht.
case "$BUILD" in failure|cancelled) echo "::error::Bau $BUILD"; exit 1 ;; esac
fi
- uses: actions/download-artifact@v4
with:
name: chart
path: dist
- name: create tag and release (Gitea API)
env:
GITEA_TOKEN: ${{ secrets.MARKT_TOKEN }}
run: |
[ -n "$GITEA_TOKEN" ] || { echo "::error::Geheimnis MARKT_TOKEN fehlt"; exit 1; }
NOTES="Lunch $VERSION — Abbild git.aimighty.olares.de/aimighty/lunch-app:$VERSION, Chart im Anhang. Automatisch nach dem Merge angelegt."
BODY=$(python3 -c 'import json,sys; print(json.dumps({"tag_name":"v"+sys.argv[1],"target_commitish":sys.argv[2],"name":"v"+sys.argv[1],"body":sys.argv[3]}))' "$VERSION" "${{ github.sha }}" "$NOTES")
RESP=$(curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" \
"$GITEA_API/repos/$GITHUB_REPOSITORY/releases" -d "$BODY")
RID=$(printf '%s' "$RESP" | python3 -c "import sys,json; print(json.load(sys.stdin).get('id') or '')")
[ -n "$RID" ] || { echo "::error::Release-Anlage fehlgeschlagen"; printf '%s\n' "$RESP" | head -c 300; exit 1; }
curl -fsS -X POST -H "Authorization: token $GITEA_TOKEN" -F "attachment=@dist/lunch-$VERSION.tgz" \
"$GITEA_API/repos/$GITHUB_REPOSITORY/releases/$RID/assets?name=lunch-$VERSION.tgz" > /dev/null
echo "Tag und Release v$VERSION angelegt"
echo "### Tag und Release v$VERSION angelegt" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"
# Der Markt-Eintrag (markt.yml) kommt mit der eigenen Anmeldung; erst
# dann geht Lunch in den Markt (docs/PROJEKTSTART.md).
+11
View File
@@ -0,0 +1,11 @@
node_modules
.next
next-env.d.ts
*.tsbuildinfo
dist
.env*
!.env.example
public/sw.js
public/sw.js.map
public/swe-worker-*.js
test-results
+19 -2
View File
@@ -7,7 +7,8 @@
> **Plattform:** Olares One (Kubernetes), Repo und CI auf Gitea — kein Supabase,
> kein Vercel (E-0001). Eigene Gestaltung, nicht AImighty (E-0002).
> Verteilung über den Markt, Repo öffentlich (E-0005).
> **Status:** Projektstart, V1 Arbeitspaket 1 als Nächstes (`docs/PROJEKTSTART.md`).
> **Status:** 26.11.1 — Gerüst, Chart, CI und Release; Arbeitspaket 1 läuft
> (Anmeldung offen, `docs/PROJEKTSTART.md`).
> **Letzte Aktualisierung:** 6. November 2026
Diese Datei ist das Gedächtnis jeder Sitzung. Entscheidungen stehen in
@@ -82,7 +83,8 @@ Datenmodells (`households`, `dishes`, `rounds`, `slots`, …).
jeder geänderten Seite (iPhone mit Safe Area: `viewport-fit=cover`,
`env(safe-area-inset-*)`).
10. **Sprache des Projekts:** Doku deutsch, Code, Bezeichner und Commits
englisch, Kommentare deutsch.
englisch, Kommentare deutsch. Die Oberfläche duzt (Familienprodukt, wie im
Konzept: „Heute kochst du“) — anders als Rocket.
---
@@ -135,6 +137,21 @@ Maßgeblich: `aimighty/plattform` → `betrieb/gitea.md`.
---
## Lokal entwickeln
```bash
createuser lunch -P && createdb -O lunch lunch # Rolle der App = Eigentümerin
export DATABASE_URL=postgres://lunch:…@localhost/lunch
npm ci && npm run migrate && npm run dev
TEST_DATABASE_URL=$DATABASE_URL npm test # mit dem Test der zwei Haushalte
bash scripts/check-chart.sh # vor jedem Commit am Chart
```
Migrationen liegen in `db/migrations/NNNN_*.sql` und laufen genau einmal
(`scripts/migrate.mjs`, Prüfsumme in `schema_migrations`). Eine angewandte
Migration wird nie geändert, sondern durch eine neue ergänzt. Auf der Box
spielt sie der Vorlauf-Container aus demselben Abbild ein.
## Tech-Stack
- **Next.js 15** (App Router) · TypeScript strict · Tailwind v4 · shadcn/ui ·
+32
View File
@@ -0,0 +1,32 @@
# Lunch — ein Abbild für Oberfläche, Server und Migrationen (E-0004).
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM node:22-alpine AS build
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Keine Telemetrie, keine Schriften vom CDN: Geist liegt im Paket `geist`.
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
FROM node:22-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
HOSTNAME=0.0.0.0 \
PORT=3000
COPY --from=build /app/public ./public
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static
# Für den Vorlauf-Container (olares/templates/deployment.yaml): pg liegt
# schon im standalone-Baum, weil der Server es benutzt.
COPY --from=build /app/scripts/migrate.mjs ./scripts/migrate.mjs
COPY --from=build /app/db/migrations ./db/migrations
USER 1000
EXPOSE 3000
CMD ["node", "server.js"]
+122
View File
@@ -0,0 +1,122 @@
# ============================================================================
# OlaresManifest.yaml — Lunch („Was gibt's?“)
#
# Linter-Regeln, die hier zwingend gelten (scripts/check-chart.sh):
# - metadata.name, metadata.appid, Chart.yaml.name und der Ordnername
# des Repos müssen alle exakt "lunch" sein
# - metadata.version = Chart.yaml.version, spec.versionName = appVersion
# - spec.requiredDisk muss gesetzt sein
# ============================================================================
olaresManifest.version: '0.12.0'
olaresManifest.type: app
apiVersion: 'v3'
workloadReplicas:
lunch: 1
metadata:
name: lunch
appid: lunch
title: What's cooking?
description: The family decides together what's for dinner — and the shopping list writes itself. Runs entirely on your own box.
icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
version: 26.11.1
categories:
- Applications
# ---- Entrance ---------------------------------------------------------------
# Einer: die App selbst. Ein Entrance bringt dem Pod einen Envoy-Sidecar, der
# jeden Aufruf gegen Authelia prüft.
#
# `internal`, solange Lunch keine eigene Anmeldung hat: Dann kommt nur herein,
# wer an der Box angemeldet ist. Auf `public` geht er erst, **nachdem** die
# eigene Anmeldung steht (E-0001) — nie umgekehrt, sonst steht die App offen.
entrances:
- name: lunch
host: lunch
port: 3000
title: What's cooking?
icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
authLevel: internal
invisible: false
openMethod: window
# ---- System-Middleware ------------------------------------------------------
# Olares stellt PostgreSQL bereit und reicht die Zugangsdaten als
# .Values.postgres.* herein.
middleware:
postgres:
username: lunch
databases:
- name: lunch
extensions:
- pgcrypto
permission:
# Die einzige Ablage, die eine Deinstallation überlebt — die Datenbank
# nicht. Hier liegen Fotos, Sicherungen und der Einrichtungscode.
appData: true
spec:
versionName: '26.11.1'
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
promoteImage:
- https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
fullDescription: |
**What's cooking?** takes the daily "what are we eating?" off the
person who usually plans.
Everyone in the family wishes for dishes in ten seconds — children
included. The app proposes a week from those wishes, the planner
approves it, and the shopping list is built from the plan, sorted by
the aisles of your store.
Everything runs on your own box: recipes, photos, receipts and the
household's data never leave the house. No telemetry, no phone home,
fonts served from the box.
developer: 'kaivo.studio'
website: 'https://aimighty.de'
sourceCode: 'https://git.aimighty.olares.de/aimighty/lunch'
license:
- text: Proprietary
url: 'https://aimighty.de'
requiredMemory: '256Mi'
limitedMemory: '768Mi'
requiredDisk: '512Mi'
limitedDisk: '5Gi'
requiredCpu: '0.1'
limitedCpu: '1'
# Nur amd64: release.yml baut nur dafür.
supportArch:
- amd64
options:
# apiVersion v3 verlangt diese Form: offen nach oben, mit '-0'.
dependencies:
- name: olares
type: system
version: '>=1.12.6-0'
allowMultipleInstall: false
# KI-Aufrufe (Bon, Kochbuchfoto) antworten synchron und dauern länger als
# die 15 Sekunden, nach denen der Sidecar sonst kappt.
apiTimeout: 0
# Ausgehend: HTTPS zu LiteLLM (öffentliche Adresse der Box) und zu
# Rezeptseiten für den Import per JSON-LD; Port 80 nur, weil manche
# Rezeptseiten erst über http umleiten.
allowedOutboundPorts:
- 443
- 80
runAsUser: "1000"
appScope:
clusterScoped: false
+7
View File
@@ -0,0 +1,7 @@
// Lebt der Prozess? Für die livenessProbe — ohne Datenbank, damit ein
// kurzer Ausfall der Datenbank den Pod nicht in eine Neustartschleife treibt.
export const dynamic = "force-dynamic";
export function GET() {
return Response.json({ ok: true });
}
+9
View File
@@ -0,0 +1,9 @@
import { databaseReachable } from "@/lib/db";
// Bereit für Anfragen? Für die readinessProbe: nur mit erreichbarer Datenbank.
export const dynamic = "force-dynamic";
export async function GET() {
const db = await databaseReachable();
return Response.json({ ok: db, db }, { status: db ? 200 : 503 });
}
+68
View File
@@ -0,0 +1,68 @@
@import "tailwindcss";
/* Farben nur als Token (E-0002): warme Palette — Creme, Terrakotta, Salbei.
Dunkler Modus von Anfang an. Werte als OKLCH, Kontrast Text/Fläche >= 4.5:1. */
:root {
--background: oklch(0.975 0.012 85); /* Creme */
--foreground: oklch(0.27 0.02 50); /* warmes Dunkelbraun */
--muted: oklch(0.935 0.018 80);
--muted-foreground: oklch(0.47 0.025 55);
--card: oklch(0.99 0.008 85);
--card-foreground: var(--foreground);
--border: oklch(0.87 0.02 75);
--primary: oklch(0.55 0.13 40); /* Terrakotta */
--primary-foreground: oklch(0.99 0.008 85);
--secondary: oklch(0.89 0.04 145); /* Salbei, hell */
--secondary-foreground: oklch(0.3 0.04 150);
--accent: oklch(0.62 0.06 150); /* Salbei */
--ring: oklch(0.55 0.13 40);
--radius: 0.875rem;
}
@media (prefers-color-scheme: dark) {
:root {
--background: oklch(0.2 0.012 55);
--foreground: oklch(0.94 0.015 80);
--muted: oklch(0.26 0.015 55);
--muted-foreground: oklch(0.74 0.02 70);
--card: oklch(0.24 0.014 55);
--border: oklch(0.34 0.015 55);
--primary: oklch(0.7 0.12 42);
--primary-foreground: oklch(0.2 0.012 55);
--secondary: oklch(0.33 0.04 150);
--secondary-foreground: oklch(0.92 0.03 145);
--accent: oklch(0.72 0.07 150);
--ring: oklch(0.7 0.12 42);
}
}
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-border: var(--border);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-accent: var(--accent);
--color-ring: var(--ring);
--radius-xl: var(--radius);
--font-sans: var(--font-geist-sans), ui-sans-serif, system-ui, sans-serif;
}
html {
color-scheme: light dark;
-webkit-text-size-adjust: 100%;
}
body {
background: var(--background);
color: var(--foreground);
font-family: var(--font-sans);
/* iPhone: Inhalt nie hinter Insel oder Home-Leiste */
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
+37
View File
@@ -0,0 +1,37 @@
import type { Metadata, Viewport } from "next";
import { GeistSans } from "geist/font/sans";
import { NextIntlClientProvider } from "next-intl";
import { getLocale, getTranslations } from "next-intl/server";
import "./globals.css";
export async function generateMetadata(): Promise<Metadata> {
const t = await getTranslations("app");
return {
title: t("name"),
description: t("tagline"),
applicationName: t("name"),
appleWebApp: { capable: true, title: t("name"), statusBarStyle: "default" },
icons: { icon: "/icon.svg", apple: "/apple-touch-icon.png" },
};
}
export const viewport: Viewport = {
width: "device-width",
initialScale: 1,
viewportFit: "cover",
themeColor: [
{ media: "(prefers-color-scheme: light)", color: "#faf6ee" },
{ media: "(prefers-color-scheme: dark)", color: "#221d19" },
],
};
export default async function RootLayout({ children }: { children: React.ReactNode }) {
const locale = await getLocale();
return (
<html lang={locale} className={GeistSans.variable}>
<body className="min-h-dvh antialiased">
<NextIntlClientProvider>{children}</NextIntlClientProvider>
</body>
</html>
);
}
+20
View File
@@ -0,0 +1,20 @@
import type { MetadataRoute } from "next";
import { getTranslations } from "next-intl/server";
export default async function manifest(): Promise<MetadataRoute.Manifest> {
const t = await getTranslations("app");
return {
name: t("name"),
short_name: t("name"),
description: t("tagline"),
start_url: "/",
display: "standalone",
background_color: "#faf6ee",
theme_color: "#faf6ee",
icons: [
{ src: "/icon-192.png", sizes: "192x192", type: "image/png" },
{ src: "/icon-512.png", sizes: "512x512", type: "image/png" },
{ src: "/icon-512-maskable.png", sizes: "512x512", type: "image/png", purpose: "maskable" },
],
};
}
+14
View File
@@ -0,0 +1,14 @@
import { CookingPot } from "lucide-react";
import { getTranslations } from "next-intl/server";
// „Heute“ — vorerst nur der leere Zustand. Er sagt, was als Nächstes kommt.
export default async function TodayPage() {
const t = await getTranslations("today");
return (
<main className="mx-auto flex min-h-dvh max-w-md flex-col items-center justify-center gap-4 px-4 text-center">
<CookingPot aria-hidden className="size-10 text-primary" strokeWidth={1.5} />
<h1 className="text-2xl font-semibold">{t("emptyTitle")}</h1>
<p className="text-muted-foreground">{t("emptyText")}</p>
</main>
);
}
+22
View File
@@ -0,0 +1,22 @@
import { defaultCache } from "@serwist/next/worker";
import type { PrecacheEntry, SerwistGlobalConfig } from "serwist";
import { Serwist } from "serwist";
// App-Shell offline. Rezepte und die Einkaufsliste als Warteschlange kommen
// mit Arbeitspaket 7 und 8 dazu.
declare global {
interface WorkerGlobalScope extends SerwistGlobalConfig {
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
}
}
declare const self: ServiceWorkerGlobalScope;
const serwist = new Serwist({
precacheEntries: self.__SW_MANIFEST,
skipWaiting: true,
clientsClaim: true,
navigationPreload: true,
runtimeCaching: defaultCache,
});
serwist.addEventListeners();
+9
View File
@@ -0,0 +1,9 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": { "config": "", "css": "app/globals.css", "baseColor": "neutral", "cssVariables": true },
"aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "hooks": "@/hooks" },
"iconLibrary": "lucide"
}
+41
View File
@@ -0,0 +1,41 @@
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
// shadcn/ui Button, Größen auf mindestens 44 px (Leitprinzip 7).
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-xl text-base font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-5 [&_svg]:shrink-0",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
outline: "border border-border bg-background hover:bg-muted",
ghost: "hover:bg-muted",
},
size: {
default: "min-h-11 px-5 py-2",
lg: "min-h-12 px-6 text-lg",
icon: "size-11",
},
},
defaultVariants: { variant: "default", size: "default" },
},
);
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
},
);
Button.displayName = "Button";
export { buttonVariants };
+27
View File
@@ -0,0 +1,27 @@
-- 0001_households.sql — Grundlage: Haushalte und die Regel für alle Fachtabellen.
--
-- Jede Fachtabelle hängt an household_id und bekommt RLS **mit FORCE**
-- (CLAUDE.md, Regel 3). Die App verbindet als Eigentümerin der Tabellen;
-- ohne FORCE wäre RLS für sie lautlos wirkungslos.
create extension if not exists pgcrypto;
-- Der Haushalt der laufenden Transaktion, gesetzt von lib/db.ts
-- (set_config('app.household_id', …, true)). Leer oder nicht gesetzt: null,
-- und keine Policy trifft zu.
create function app_household_id() returns uuid
language sql stable
as $$ select nullif(current_setting('app.household_id', true), '')::uuid $$;
create table households (
id uuid primary key default gen_random_uuid(),
name text not null check (length(trim(name)) between 1 and 80),
created_at timestamptz not null default now()
);
alter table households enable row level security;
alter table households force row level security;
create policy households_member on households
using (id = app_household_id())
with check (id = app_household_id());
+9 -1
View File
@@ -12,7 +12,8 @@ Secrets nur mit Namen, nie mit Wert.
| Clone | `https://git.aimighty.olares.de/aimighty/lunch.git` |
| Issues, PRs, Releases | im Repo; Gitea-API `https://git.aimighty.olares.de/api/v1/repos/aimighty/lunch` |
| Actions | `.github/workflows/*.yml`, Runner `olares-runner` (`ubuntu-latest`) |
| Registry (Abbilder) | `git.aimighty.olares.de/aimighty/lunch-frontend`, `…/lunch-backend` |
| Registry (Abbild) | `git.aimighty.olares.de/aimighty/lunch-app` (eines, E-0004) |
| Bilder für Markt und Manifest | `aimighty/bilder` → `lunch/icon.png` (Quelle `docs/icon/lunch.svg`, erzeugt mit `scripts/app-icons.mjs`) |
| Werkzeuge für die CI | `aimighty/ci-tools`, Releases (z. B. `helm-3.16.2`) |
| Plattform-Entscheidungen | `aimighty/plattform` (`entscheidungen/`, `werkzeug/apps.json`) |
| Gitea-Betrieb | `aimighty/plattform` → `betrieb/gitea.md` |
@@ -39,6 +40,13 @@ Das Repo erbt sie, weil es in der Organisation liegt.
`olares-cli chart lint`); Release-Workflow (Abbild in die Registry, Tag
`vYY.M.n`, Chart als Anhang); Anmeldung per Magic Link und Passkey,
Haushalt anlegen; erst dann Entrance `public`.
**Stand:** Gerüst, Chart (Entrance `internal`), CI und Release in
`26.11.1`. `olares-cli chart lint` läuft noch nicht in der CI (der Runner
hat das Werkzeug nicht) — Prüfung vor dem Markt von Hand, wie bei Rocket.
Offen in Paket 1: Anmeldung (Einrichtungscode, Passkey, Einladung, Magic
Link sobald SMTP feststeht), Haushalt anlegen, dann `public` und der
Markt-Eintrag (`markt.yml`).
2. **Datenmodell** als Migrationen (22 Tabellen, RLS mit FORCE), Test mit zwei Haushalten; Sicherung nach `/app/data`.
3. **Seed:** etwa 300 kanonische Zutaten in vier Sprachen, Starter-Pool DE und EN, Gangfolgen REWE, Edeka, Lidl, Aldi.
4. **Gerichte:** von Hand, Import per JSON-LD, Foto-Import über LiteLLM.
+15
View File
@@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<rect width="512" height="512" rx="112" fill="#b8573a"/>
<!-- Teller -->
<circle cx="256" cy="292" r="142" fill="#faf6ee"/>
<circle cx="256" cy="292" r="98" fill="none" stroke="#e7dccb" stroke-width="14"/>
<!-- Dampf -->
<g fill="none" stroke="#faf6ee" stroke-width="18" stroke-linecap="round">
<path d="M206 78c-16 18 16 30 0 48"/>
<path d="M256 64c-16 20 16 34 0 54"/>
<path d="M306 78c-16 18 16 30 0 48"/>
</g>
<!-- Salbeiblatt -->
<path d="M206 316c20-62 86-82 116-72-6 52-58 98-116 72z" fill="#8aa486"/>
<path d="M214 312c30-24 58-42 96-62" stroke="#faf6ee" stroke-width="7" stroke-linecap="round" fill="none"/>
</svg>

After

Width:  |  Height:  |  Size: 719 B

+13
View File
@@ -0,0 +1,13 @@
import { cookies, headers } from "next/headers";
import { getRequestConfig } from "next-intl/server";
import { LOCALE_COOKIE, resolveLocale } from "@/lib/locale";
// Ohne Sprache in der Adresse: Ein Link aus dem Familien-Chat soll bei jeder
// Person in ihrer eigenen Sprache aufgehen.
export default getRequestConfig(async () => {
const locale = resolveLocale((await cookies()).get(LOCALE_COOKIE)?.value, (await headers()).get("accept-language"));
return {
locale,
messages: (await import(`../messages/${locale}.json`)).default,
};
});
+55
View File
@@ -0,0 +1,55 @@
import "server-only";
import { Pool, type PoolClient } from "pg";
// Zugang zur Postgres von Olares. Die Werte injiziert das Chart aus
// .Values.postgres.* (CLAUDE.md, Olares-Regel 5) — nie hartkodieren.
// Lokal reicht DATABASE_URL.
function createPool(): Pool {
if (process.env.DATABASE_URL) return new Pool({ connectionString: process.env.DATABASE_URL, max: 10 });
return new Pool({
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT ?? 5432),
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
max: 10,
});
}
const globalForPool = globalThis as unknown as { lunchPool?: Pool };
export const pool: Pool = globalForPool.lunchPool ?? createPool();
if (process.env.NODE_ENV !== "production") globalForPool.lunchPool = pool;
/**
* Führt `fn` in einer Transaktion im Namen eines Haushalts aus.
*
* Jede Fachtabelle hat RLS mit FORCE und die Policy „Mitglied des Haushalts“
* über `app.household_id`. Ohne diesen Aufruf sieht eine Abfrage nichts —
* die App verbindet als Tabelleneigentümerin, FORCE ist die einzige Wand.
* `set_config(…, true)` gilt nur bis zum Ende der Transaktion; ein Client,
* der in den Pool zurückgeht, trägt keinen Haushalt weiter.
*/
export async function withHousehold<T>(householdId: string, fn: (client: PoolClient) => Promise<T>): Promise<T> {
const client = await pool.connect();
try {
await client.query("begin");
await client.query("select set_config('app.household_id', $1, true)", [householdId]);
const result = await fn(client);
await client.query("commit");
return result;
} catch (error) {
await client.query("rollback").catch(() => undefined);
throw error;
} finally {
client.release();
}
}
export async function databaseReachable(): Promise<boolean> {
try {
await pool.query("select 1");
return true;
} catch {
return false;
}
}
+31
View File
@@ -0,0 +1,31 @@
// Sprachen der App. Die Sprache gehört der Person (CLAUDE.md, Regel 1):
// gewählt im Profil (Keks `lunch_locale`), sonst aus dem Browser, sonst Deutsch.
export const LOCALES = ["de", "en", "fr", "es"] as const;
export type Locale = (typeof LOCALES)[number];
export const DEFAULT_LOCALE: Locale = "de";
export const LOCALE_COOKIE = "lunch_locale";
export function isLocale(value: unknown): value is Locale {
return typeof value === "string" && (LOCALES as readonly string[]).includes(value);
}
/** Wählt aus einem Accept-Language-Kopf die beste unterstützte Sprache. */
export function negotiateLocale(acceptLanguage: string | null | undefined): Locale {
if (!acceptLanguage) return DEFAULT_LOCALE;
const candidates = acceptLanguage
.split(",")
.map((part, index) => {
const [tag = "", ...params] = part.trim().split(";");
const q = params.map((p) => p.trim()).find((p) => p.startsWith("q="));
const weight = q ? Number(q.slice(2)) : 1;
return { lang: tag.toLowerCase().split("-")[0] ?? "", weight: Number.isFinite(weight) ? weight : 0, index };
})
.filter((c) => c.lang && c.weight > 0)
.sort((a, b) => b.weight - a.weight || a.index - b.index);
for (const c of candidates) if (isLocale(c.lang)) return c.lang;
return DEFAULT_LOCALE;
}
export function resolveLocale(cookieValue: string | undefined, acceptLanguage: string | null): Locale {
return isLocale(cookieValue) ? cookieValue : negotiateLocale(acceptLanguage);
}
+6
View File
@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
+10
View File
@@ -0,0 +1,10 @@
{
"app": {
"name": "Was gibt's?",
"tagline": "Gemeinsam entscheiden, was es gibt — die Einkaufsliste entsteht von selbst."
},
"today": {
"emptyTitle": "Noch kein Plan",
"emptyText": "Sobald die erste Planungsrunde steht, siehst du hier, was es heute gibt und wer kocht."
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"app": {
"name": "What's cooking?",
"tagline": "Decide together what's for dinner — the shopping list writes itself."
},
"today": {
"emptyTitle": "No plan yet",
"emptyText": "Once the first planning round is set, you'll see here what's for dinner today and who's cooking."
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"app": {
"name": "¿Qué comemos?",
"tagline": "Decide together what's for dinner — the shopping list writes itself."
},
"today": {
"emptyTitle": "No plan yet",
"emptyText": "Once the first planning round is set, you'll see here what's for dinner today and who's cooking."
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"app": {
"name": "On mange quoi ?",
"tagline": "Decide together what's for dinner — the shopping list writes itself."
},
"today": {
"emptyTitle": "No plan yet",
"emptyText": "Once the first planning round is set, you'll see here what's for dinner today and who's cooking."
}
}
+26
View File
@@ -0,0 +1,26 @@
import type { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin";
import withSerwistInit from "@serwist/next";
// Serwist baut den Service Worker aus app/sw.ts nach public/sw.js.
// In der Entwicklung aus: Ein Service Worker, der alte Stände ausliefert,
// macht jedes Neuladen zur Rätselfrage.
const withSerwist = withSerwistInit({
swSrc: "app/sw.ts",
swDest: "public/sw.js",
disable: process.env.NODE_ENV !== "production",
});
const withNextIntl = createNextIntlPlugin("./i18n/request.ts");
const nextConfig: NextConfig = {
reactStrictMode: true,
// Standalone: Das Abbild trägt nur, was zur Laufzeit gebraucht wird.
output: "standalone",
// pg lädt optionale Module dynamisch; nicht bündeln, sondern als Paket
// mitnehmen (standalone verfolgt es dann selbst).
serverExternalPackages: ["pg"],
poweredByHeader: false,
};
export default withSerwist(withNextIntl(nextConfig));
+6
View File
@@ -0,0 +1,6 @@
apiVersion: v2
name: lunch
description: Was gibt's? — die Familie entscheidet gemeinsam, was es gibt; aus dem Plan entsteht die Einkaufsliste
type: application
version: 26.11.1 # YY.M.<n> wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen
appVersion: "26.11.1" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran
+122
View File
@@ -0,0 +1,122 @@
# ============================================================================
# OlaresManifest.yaml — Lunch („Was gibt's?“)
#
# Linter-Regeln, die hier zwingend gelten (scripts/check-chart.sh):
# - metadata.name, metadata.appid, Chart.yaml.name und der Ordnername
# des Repos müssen alle exakt "lunch" sein
# - metadata.version = Chart.yaml.version, spec.versionName = appVersion
# - spec.requiredDisk muss gesetzt sein
# ============================================================================
olaresManifest.version: '0.12.0'
olaresManifest.type: app
apiVersion: 'v3'
workloadReplicas:
lunch: 1
metadata:
name: lunch
appid: lunch
title: What's cooking?
description: The family decides together what's for dinner — and the shopping list writes itself. Runs entirely on your own box.
icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
version: 26.11.1
categories:
- Applications
# ---- Entrance ---------------------------------------------------------------
# Einer: die App selbst. Ein Entrance bringt dem Pod einen Envoy-Sidecar, der
# jeden Aufruf gegen Authelia prüft.
#
# `internal`, solange Lunch keine eigene Anmeldung hat: Dann kommt nur herein,
# wer an der Box angemeldet ist. Auf `public` geht er erst, **nachdem** die
# eigene Anmeldung steht (E-0001) — nie umgekehrt, sonst steht die App offen.
entrances:
- name: lunch
host: lunch
port: 3000
title: What's cooking?
icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
authLevel: internal
invisible: false
openMethod: window
# ---- System-Middleware ------------------------------------------------------
# Olares stellt PostgreSQL bereit und reicht die Zugangsdaten als
# .Values.postgres.* herein.
middleware:
postgres:
username: lunch
databases:
- name: lunch
extensions:
- pgcrypto
permission:
# Die einzige Ablage, die eine Deinstallation überlebt — die Datenbank
# nicht. Hier liegen Fotos, Sicherungen und der Einrichtungscode.
appData: true
spec:
versionName: '26.11.1'
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
promoteImage:
- https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
fullDescription: |
**What's cooking?** takes the daily "what are we eating?" off the
person who usually plans.
Everyone in the family wishes for dishes in ten seconds — children
included. The app proposes a week from those wishes, the planner
approves it, and the shopping list is built from the plan, sorted by
the aisles of your store.
Everything runs on your own box: recipes, photos, receipts and the
household's data never leave the house. No telemetry, no phone home,
fonts served from the box.
developer: 'kaivo.studio'
website: 'https://aimighty.de'
sourceCode: 'https://git.aimighty.olares.de/aimighty/lunch'
license:
- text: Proprietary
url: 'https://aimighty.de'
requiredMemory: '256Mi'
limitedMemory: '768Mi'
requiredDisk: '512Mi'
limitedDisk: '5Gi'
requiredCpu: '0.1'
limitedCpu: '1'
# Nur amd64: release.yml baut nur dafür.
supportArch:
- amd64
options:
# apiVersion v3 verlangt diese Form: offen nach oben, mit '-0'.
dependencies:
- name: olares
type: system
version: '>=1.12.6-0'
allowMultipleInstall: false
# KI-Aufrufe (Bon, Kochbuchfoto) antworten synchron und dauern länger als
# die 15 Sekunden, nach denen der Sidecar sonst kappt.
apiTimeout: 0
# Ausgehend: HTTPS zu LiteLLM (öffentliche Adresse der Box) und zu
# Rezeptseiten für den Import per JSON-LD; Port 80 nur, weil manche
# Rezeptseiten erst über http umleiten.
allowedOutboundPorts:
- 443
- 80
runAsUser: "1000"
appScope:
clusterScoped: false
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

+5
View File
@@ -0,0 +1,5 @@
# First build
v26.11.1: First build of What's cooking? on Olares: the app shell in four languages (German, English, French, Spanish), installable as an app on the phone, with its own database and the basis for keeping each household's data apart. Reachable only for people signed in to the box until its own sign-in follows.
## Deutsch
v26.11.1: Erster Bau von Was gibt's? auf Olares: die Hülle der App in vier Sprachen (Deutsch, Englisch, Französisch, Spanisch), als App aufs Handy installierbar, mit eigener Datenbank und der Grundlage, die Daten jedes Haushalts voneinander zu trennen. Erreichbar nur für Personen, die an der Box angemeldet sind, bis die eigene Anmeldung folgt.
+15
View File
@@ -0,0 +1,15 @@
{{/*
Zugang zur Datenbank, für Vorlauf- und App-Container gleich.
*/}}
{{- define "lunch.dbEnv" -}}
- name: DB_HOST
value: "{{ .Values.postgres.host }}"
- name: DB_PORT
value: "{{ .Values.postgres.port }}"
- name: DB_USER
value: "{{ .Values.postgres.username }}"
- name: DB_PASSWORD
value: "{{ .Values.postgres.password }}"
- name: DB_NAME
value: "{{ .Values.postgres.databases.lunch }}"
{{- end -}}
+95
View File
@@ -0,0 +1,95 @@
# ============================================================================
# Lunch — ein Deployment für Oberfläche und Server (E-0004), dazu zwei
# Vorlauf-Container: Rechte an /app/data setzen, Migrationen einspielen.
#
# metadata.name ist der literale App-Name — Olares verlangt das.
# Die Zugangsdaten zur Datenbank injiziert Olares als .Values.postgres.*,
# weil middleware: postgres deklariert ist. Nichts davon steht fest im Code.
# ============================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: lunch
namespace: {{ .Release.Namespace }}
labels:
app: lunch
spec:
replicas: {{ (index .Values.workloads "lunch").replicaCount }}
# Recreate statt RollingUpdate: /app/data hängt per hostPath. Zwei Pods auf
# demselben Verzeichnis kämen sich in die Quere, und der Markt lehnt
# hostPath + RollingUpdate ab.
strategy:
type: Recreate
selector:
matchLabels:
app: lunch
template:
metadata:
labels:
app: lunch
spec:
initContainers:
# /app/data gehört anfangs root; die App läuft als 1000.
- name: init-chown
image: docker.io/beclab/aboveos-busybox:1.37.0
command: ['sh', '-c', 'chown -R 1000:1000 /app/data']
securityContext:
runAsUser: 0
volumeMounts:
- name: app-data
mountPath: /app/data
# Schema und Zeilensicherheit. Kein Helm-Hook: Ein Hook liefe vor dem
# ns-owner-Label, und die NetworkPolicy sperrte den Weg zur Datenbank.
# scripts/migrate.mjs wartet mit Wiederholschleife, bis er frei ist.
- name: migrate
# Pfad fest, nicht aus values.yaml: Ein Upgrade spielt die Werte der
# Installation zurück (CLAUDE.md, Olares-Regel 6).
image: "git.aimighty.olares.de/aimighty/lunch-app:{{ .Values.images.app.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.images.app.pullPolicy }}
command: ["node", "scripts/migrate.mjs"]
securityContext:
runAsUser: 1000
runAsNonRoot: true
env:
{{- include "lunch.dbEnv" . | nindent 12 }}
containers:
- name: app
image: "git.aimighty.olares.de/aimighty/lunch-app:{{ .Values.images.app.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.images.app.pullPolicy }}
securityContext:
runAsUser: 1000
runAsNonRoot: true
ports:
- containerPort: 3000
name: http
env:
{{- include "lunch.dbEnv" . | nindent 12 }}
- name: APP_DATA_DIR
value: /app/data
- name: NEXT_TELEMETRY_DISABLED
value: "1"
volumeMounts:
- name: app-data
mountPath: /app/data
resources:
{{ toYaml .Values.resources.app | indent 12 }}
readinessProbe:
httpGet:
path: /api/ready
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 20
periodSeconds: 30
volumes:
- name: app-data
hostPath:
type: DirectoryOrCreate
path: {{ .Values.userspace.appData }}
+18
View File
@@ -0,0 +1,18 @@
# Nur ClusterIP. Kein NodePort, kein LoadBalancer, kein hostNetwork — von
# außen führt der Weg ausschließlich über den deklarierten Entrance.
apiVersion: v1
kind: Service
metadata:
name: lunch
namespace: {{ .Release.Namespace }}
labels:
app: lunch
spec:
type: ClusterIP
selector:
app: lunch
ports:
- name: http
port: 3000
targetPort: 3000
protocol: TCP
+15
View File
@@ -0,0 +1,15 @@
# Nur zum Prüfen mit `helm lint` und `helm template`. Die echten Werte
# injiziert Olares zur Laufzeit; dieses Blatt tut nur so, als wären sie da.
postgres:
host: postgres-cluster.os-platform
port: "5432"
username: lunch
password: nur-zum-pruefen
databases:
lunch: lunch-db
bfl:
username: pruefer
user:
zone: pruefer.olares.com
userspace:
appData: /olares/userdata/Cache/pruefer/lunch
+32
View File
@@ -0,0 +1,32 @@
# ============================================================================
# values.yaml — Vorgabewerte für Lunch
#
# Olares injiziert zur Laufzeit zusätzlich:
# .Values.bfl.username, .Values.user.zone
# .Values.userspace.appData
# .Values.postgres.* (weil middleware: postgres deklariert ist)
# ============================================================================
# Replikatzahl. Olares überschreibt sie zur Laufzeit (Installation, Anhalten,
# Fortsetzen); das Template liest ausschließlich von hier.
workloads:
"lunch":
replicaCount: 1
# `tag` bleibt leer: Der wirksame Tag ist Chart.AppVersion. Ein Upgrade über
# den Markt spielt die Werte der *Installation* zurück — ein Tag hier fröre
# fest (CLAUDE.md, Olares-Regel 6). Der Abbild-Pfad steht aus demselben Grund
# fest im Template.
images:
app:
tag: ""
pullPolicy: IfNotPresent
resources:
app:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 768Mi
+4761
View File
File diff suppressed because it is too large. Load diff
+41
View File
@@ -0,0 +1,41 @@
{
"name": "lunch",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"type-check": "tsc --noEmit",
"test": "vitest run",
"migrate": "node scripts/migrate.mjs"
},
"dependencies": {
"@radix-ui/react-slot": "^1.5.0",
"@serwist/next": "^9.5.13",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"geist": "^1.9.2",
"lucide-react": "^1.70.0",
"next": "15.5.29",
"next-intl": "^4.14.9",
"pg": "^8.23.1",
"react": "19.2.0",
"react-dom": "19.2.0",
"server-only": "^0.0.1",
"serwist": "^9.5.13",
"tailwind-merge": "^3.7.0",
"zod": "^4.6.7"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.3.5",
"@types/node": "^22.20.5",
"@types/pg": "^8.23.1",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"postcss": "^8.5.32",
"tailwindcss": "^4.3.5",
"typescript": "^5.9.3",
"vitest": "^3.2.7"
}
}
+1
View File
@@ -0,0 +1 @@
export default { plugins: { "@tailwindcss/postcss": {} } };
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

+15
View File
@@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<rect width="512" height="512" rx="112" fill="#b8573a"/>
<!-- Teller -->
<circle cx="256" cy="292" r="142" fill="#faf6ee"/>
<circle cx="256" cy="292" r="98" fill="none" stroke="#e7dccb" stroke-width="14"/>
<!-- Dampf -->
<g fill="none" stroke="#faf6ee" stroke-width="18" stroke-linecap="round">
<path d="M206 78c-16 18 16 30 0 48"/>
<path d="M256 64c-16 20 16 34 0 54"/>
<path d="M306 78c-16 18 16 30 0 48"/>
</g>
<!-- Salbeiblatt -->
<path d="M206 316c20-62 86-82 116-72-6 52-58 98-116 72z" fill="#8aa486"/>
<path d="M214 312c30-24 58-42 96-62" stroke="#faf6ee" stroke-width="7" stroke-linecap="round" fill="none"/>
</svg>

After

Width:  |  Height:  |  Size: 719 B

+31
View File
@@ -0,0 +1,31 @@
// Erzeugt die Symbole der PWA aus docs/icon/lunch.svg (Chromium über
// Playwright, nur lokal nötig): public/icon.svg, apple-touch-icon.png,
// icon-192.png, icon-512.png, icon-512-maskable.png und olares/icon.png (512 × 512, geht als lunch/icon.png nach aimighty/bilder).
// Ändert sich das Symbol, alle neu erzeugen und mit committen.
import { copyFile, readFile } from "node:fs/promises";
import { createRequire } from "node:module";
// Playwright ist keine Abhängigkeit des Projekts; global installiert reicht.
const { chromium } = createRequire(import.meta.url)("playwright");
const svg = await readFile("docs/icon/lunch.svg", "utf8");
const browser = await chromium.launch();
const page = await browser.newPage();
async function render(file, size, { maskable = false } = {}) {
// Maskierbar: Motiv auf 80 % in sicherer Zone, Rand in Terrakotta.
const inner = maskable ? Math.round(size * 0.8) : size;
await page.setViewportSize({ width: size, height: size });
await page.setContent(`<html><body style="margin:0;background:${maskable ? "#b8573a" : "transparent"};display:grid;place-items:center;width:${size}px;height:${size}px">
<div style="width:${inner}px;height:${inner}px">${svg.replace("<svg ", `<svg width="${inner}" height="${inner}" `)}</div></body></html>`);
await page.screenshot({ path: file, omitBackground: !maskable });
}
await copyFile("docs/icon/lunch.svg", "public/icon.svg");
await render("public/apple-touch-icon.png", 180, { maskable: true });
await render("public/icon-192.png", 192);
await render("public/icon-512.png", 512);
await render("public/icon-512-maskable.png", 512, { maskable: true });
await render("olares/icon.png", 512);
await browser.close();
console.log("icons written");
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
# Prüft das Olares-Chart vor jedem Commit und in der CI. Jede Regel steht
# für einen Fehler, der bei Rocket oder Insilo auf der Box Geld gekostet hat
# (Vorbild: aimighty/rocket scripts/check-chart.sh).
set -euo pipefail
cd "$(dirname "$0")/.."
FEHLER=0
melde() { echo " FEHLER: $*"; FEHLER=1; }
echo "→ Versionen im Gleichschritt"
CHART_VERSION=$(grep -E '^version:' olares/Chart.yaml | awk '{print $2}')
CHART_APPVERSION=$(grep -E '^appVersion:' olares/Chart.yaml | awk '{print $2}' | tr -d '"')
MANIFEST_VERSION=$(grep -E '^ version:' olares/OlaresManifest.yaml | awk '{print $2}')
MANIFEST_VERSIONNAME=$(grep -E '^ versionName:' olares/OlaresManifest.yaml | awk '{print $2}' | tr -d "'")
[ "$CHART_VERSION" = "$CHART_APPVERSION" ] || melde "Chart.yaml: version ($CHART_VERSION) != appVersion ($CHART_APPVERSION)"
[ "$CHART_VERSION" = "$MANIFEST_VERSION" ] || melde "OlaresManifest metadata.version ($MANIFEST_VERSION) != Chart-version ($CHART_VERSION)"
[ "$CHART_APPVERSION" = "$MANIFEST_VERSIONNAME" ] || melde "OlaresManifest spec.versionName ($MANIFEST_VERSIONNAME) != appVersion ($CHART_APPVERSION)"
# YY.M.<n>, Monat ohne führende Null — mit Null ist es kein gültiges SemVer.
echo "$CHART_VERSION" | grep -Eq '^[0-9]{2}\.([1-9]|1[0-2])\.[1-9][0-9]*$' \
|| melde "Version '$CHART_VERSION' folgt nicht YY.M.<n> (z. B. 26.11.1)"
echo "→ Root-Manifest ist eine Kopie des Chart-Manifests"
cmp -s OlaresManifest.yaml olares/OlaresManifest.yaml \
|| melde "OlaresManifest.yaml (Wurzel) weicht von olares/OlaresManifest.yaml ab — cp olares/OlaresManifest.yaml ."
echo "→ Namen identisch (Chart, metadata.name, appid)"
for wert in \
"$(grep -E '^name:' olares/Chart.yaml | awk '{print $2}')" \
"$(grep -E '^ name: ' olares/OlaresManifest.yaml | head -1 | awk '{print $2}')" \
"$(grep -E '^ appid:' olares/OlaresManifest.yaml | awk '{print $2}')"
do
[ "$wert" = "lunch" ] || melde "Name weicht ab: '$wert' (erwartet: lunch)"
done
ohne_kommentare() { grep -rhvE '^[[:space:]]*#' olares/templates/; }
suche_verboten() {
if ohne_kommentare | grep -qE "$1"; then melde "$2 gefunden"; ohne_kommentare | grep -nE "$1" | head -3; fi
}
echo "→ Kein .Files.Get, keine Helm-Hooks, kein NodePort/LoadBalancer/hostNetwork"
suche_verboten '\.Files\.Get' ".Files.Get"
suche_verboten 'helm\.sh/hook' "Helm-Hook"
suche_verboten 'NodePort|LoadBalancer|hostNetwork' "verbotener Netzwerktyp"
echo "→ Manifest v3"
API_VERSION=$(grep -E '^apiVersion:' olares/OlaresManifest.yaml | awk '{print $2}' | tr -d "'\"")
DEP_VERSION=$(awk '/^[[:space:]]*-[[:space:]]*name:[[:space:]]*olares[[:space:]]*$/{f=1} f&&/^[[:space:]]*version:/{gsub(/.*version:[[:space:]]*/,""); gsub(/['"'"'"]/,""); print; exit}' olares/OlaresManifest.yaml)
[ "$API_VERSION" = "v3" ] || melde "OlaresManifest ohne apiVersion v3"
[ "$DEP_VERSION" = ">=1.12.6-0" ] || melde "options.dependencies[olares].version muss '>=1.12.6-0' sein, ist '$DEP_VERSION'"
grep -qE '^[[:space:]]*runAsInternal:[[:space:]]*true' olares/OlaresManifest.yaml && melde "runAsInternal: true im Manifest"
grep -rq 'OLARES_USER' olares/ && melde "OLARES_USER kommt in olares/ vor (v3 verbietet das Präfix)"
for tpl in olares/templates/deployment*.yaml; do
grep -q 'index .Values.workloads' "$tpl" || melde "$tpl liest replicas nicht aus .Values.workloads"
done
echo "→ Abbild: Pfad fest im Template, Tag aus Chart.AppVersion"
if grep -n 'image:' olares/templates/deployment*.yaml | grep -q 'repository'; then
melde "ein Template liest den Abbild-Pfad aus values.yaml"
fi
grep -q 'image: "git.aimighty.olares.de/aimighty/lunch-app:' olares/templates/deployment.yaml \
|| melde "deployment.yaml zieht nicht git.aimighty.olares.de/aimighty/lunch-app"
grep -q 'default .Chart.AppVersion' olares/templates/deployment.yaml \
|| melde "deployment.yaml liest den Tag nicht aus Chart.AppVersion"
if grep -qE '^\s+tag: "[^"]+"' olares/values.yaml; then
echo " Hinweis: values.yaml pinnt einen Tag — nur für ein Release ohne neue Abbilder richtig."
fi
echo "→ Bilder aus aimighty/bilder, nichts von GitHub"
grep -qi 'github' olares/OlaresManifest.yaml && melde "OlaresManifest.yaml nennt GitHub"
BILDER="https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/"
for feld in icon featuredImage; do
grep -E "^[[:space:]]*$feld:" olares/OlaresManifest.yaml | grep -vqF "$BILDER" && melde "$feld liegt nicht unter $BILDER"
done
echo "→ Entrance erst public, wenn die eigene Anmeldung steht (E-0001)"
if grep -qE '^[[:space:]]*authLevel:[[:space:]]*public' olares/OlaresManifest.yaml && [ ! -f lib/auth/session.ts ]; then
melde "Entrance ist public, aber lib/auth/session.ts fehlt — erst die eigene Anmeldung, dann öffnen"
fi
echo "→ Markt-Notiz zur Version"
MV="$CHART_VERSION"
if [ ! -f "olares/markt/$MV.md" ]; then
melde "olares/markt/$MV.md fehlt — '# Titel', 'v$MV: …' (Englisch), '## Deutsch', 'v$MV: …'"
else
head -1 "olares/markt/$MV.md" | grep -q '^# ' || melde "olares/markt/$MV.md: erste Zeile '# <Titel>'"
sed -n 2p "olares/markt/$MV.md" | grep -q "^v$MV: " || melde "olares/markt/$MV.md: Text beginnt mit 'v$MV: '"
! grep -q '`' "olares/markt/$MV.md" || melde "olares/markt/$MV.md: kein Backtick"
awk '/^## Deutsch[[:space:]]*$/{f=1;next} f&&NF{print;exit}' "olares/markt/$MV.md" | grep -q "^v$MV: " \
|| melde "olares/markt/$MV.md: deutscher Teil fehlt — Zeile '## Deutsch', darunter 'v$MV: …'"
fi
echo "→ helm lint und helm template"
helm lint olares -f olares/values-olares-stub.yaml > /dev/null || melde "helm lint fehlgeschlagen"
helm template lunch olares -f olares/values-olares-stub.yaml > /dev/null || melde "helm template fehlgeschlagen"
if [ "$FEHLER" -eq 0 ]; then echo "Alles in Ordnung."; else echo "Prüfung fehlgeschlagen."; exit 1; fi
+83
View File
@@ -0,0 +1,83 @@
// Spielt db/migrations/*.sql in Namensreihenfolge ein — als Vorlauf-Container
// auf der Box (olares/templates/deployment.yaml) und lokal mit `npm run migrate`.
//
// Jede Datei läuft einmal, in einer eigenen Transaktion, und wird mit
// Prüfsumme in schema_migrations vermerkt. Eine schon angewandte Datei, deren
// Inhalt sich geändert hat, ist ein Fehler: Migrationen werden nie
// nachträglich bearbeitet, sondern durch eine neue ergänzt.
//
// Die Wiederholschleife beim Verbinden deckt das Fenster ab, in dem Olares
// das ns-owner-Label noch nicht gesetzt hat und die NetworkPolicy den Weg zur
// Datenbank sperrt (bei Insilo und Rocket gelernt; kein Helm-Hook).
import { createHash } from "node:crypto";
import { readdir, readFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
import pg from "pg";
const DIR = process.env.MIGRATIONS_DIR ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "db", "migrations");
function config() {
if (process.env.DATABASE_URL) return { connectionString: process.env.DATABASE_URL };
return {
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT ?? 5432),
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
};
}
async function connect(attempts = Number(process.env.MIGRATE_ATTEMPTS ?? 60), pause = 5000) {
let last;
for (let i = 1; i <= attempts; i++) {
const client = new pg.Client({ ...config(), connectionTimeoutMillis: 4000 });
try {
await client.connect();
return client;
} catch (error) {
last = error;
console.log(` attempt ${i}/${attempts}: ${error.message}`);
await client.end().catch(() => {});
if (i < attempts) await new Promise((r) => setTimeout(r, pause));
}
}
throw last;
}
async function main() {
console.log("waiting for postgres …");
const client = await connect();
try {
await client.query(`create table if not exists schema_migrations (
name text primary key, checksum text not null, applied_at timestamptz not null default now())`);
const done = new Map((await client.query("select name, checksum from schema_migrations")).rows.map((r) => [r.name, r.checksum]));
const files = (await readdir(DIR)).filter((f) => f.endsWith(".sql")).sort();
for (const file of files) {
const sql = await readFile(path.join(DIR, file), "utf8");
const sum = createHash("sha256").update(sql).digest("hex");
if (done.has(file)) {
if (done.get(file) !== sum) throw new Error(`${file} was changed after it was applied — add a new migration instead`);
continue;
}
console.log(`applying ${file}`);
await client.query("begin");
try {
await client.query(sql);
await client.query("insert into schema_migrations (name, checksum) values ($1, $2)", [file, sum]);
await client.query("commit");
} catch (error) {
await client.query("rollback");
throw new Error(`${file}: ${error.message}`);
}
}
console.log(`migrations up to date (${files.length} files)`);
} finally {
await client.end();
}
}
main().catch((error) => {
console.error(error.message);
process.exit(1);
});
+21
View File
@@ -0,0 +1,21 @@
import { describe, expect, it } from "vitest";
import { negotiateLocale, resolveLocale } from "@/lib/locale";
describe("negotiateLocale", () => {
it("falls back to German", () => {
expect(negotiateLocale(null)).toBe("de");
expect(negotiateLocale("ja,zh;q=0.8")).toBe("de");
});
it("respects quality values and region tags", () => {
expect(negotiateLocale("fr-CH, fr;q=0.9, en;q=0.8")).toBe("fr");
expect(negotiateLocale("it;q=1, es-ES;q=0.7, en;q=0.9")).toBe("en");
expect(negotiateLocale("en;q=0, es")).toBe("es");
});
});
describe("resolveLocale", () => {
it("prefers the person's choice over the browser", () => {
expect(resolveLocale("es", "de-DE")).toBe("es");
expect(resolveLocale("xx", "en-GB")).toBe("en");
});
});
+62
View File
@@ -0,0 +1,62 @@
import { randomUUID } from "node:crypto";
import pg from "pg";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
// Der Test mit zwei Haushalten (CLAUDE.md, Regel 3). Läuft gegen eine
// migrierte Datenbank als Eigentümerin der Tabellen — genau wie die App auf
// der Box. Ohne FORCE sähe diese Rolle alles, und der Test bräche.
const url = process.env.TEST_DATABASE_URL;
describe.skipIf(!url)("row level security", () => {
const client = new pg.Client({ connectionString: url });
const a = randomUUID();
const b = randomUUID();
async function asHousehold<T>(id: string | null, fn: () => Promise<T>): Promise<T> {
await client.query("begin");
try {
if (id) await client.query("select set_config('app.household_id', $1, true)", [id]);
return await fn();
} finally {
await client.query("commit");
}
}
beforeAll(async () => {
await client.connect();
await asHousehold(a, () => client.query("insert into households (id, name) values ($1, 'A')", [a]));
await asHousehold(b, () => client.query("insert into households (id, name) values ($1, 'B')", [b]));
});
afterAll(async () => {
await client.end();
});
it("every table with household data forces RLS", async () => {
const { rows } = await client.query(`
select c.relname, c.relrowsecurity, c.relforcerowsecurity
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind = 'r' and c.relname <> 'schema_migrations'`);
expect(rows.length).toBeGreaterThan(0);
for (const r of rows) expect([r.relname, r.relrowsecurity, r.relforcerowsecurity]).toEqual([r.relname, true, true]);
});
it("a household sees only itself", async () => {
const seen = await asHousehold(a, () => client.query("select id from households"));
expect(seen.rows.map((r) => r.id)).toEqual([a]);
});
it("without a household nothing is visible", async () => {
const seen = await asHousehold(null, () => client.query("select count(*)::int as n from households"));
expect(seen.rows[0].n).toBe(0);
});
it("a household cannot write into another", async () => {
await expect(
asHousehold(a, () => client.query("update households set name = 'X' where id = $1 returning id", [b])),
).resolves.toMatchObject({ rowCount: 0 });
await expect(
asHousehold(a, () => client.query("insert into households (id, name) values ($1, 'C')", [randomUUID()])),
).rejects.toThrow(/row-level security/);
});
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["dom", "dom.iterable", "esnext", "webworker"],
"allowJs": false,
"skipLibCheck": true,
"strict": true,
"noUncheckedIndexedAccess": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"types": ["@serwist/next/typings"],
"plugins": [{ "name": "next" }],
"paths": { "@/*": ["./*"] }
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules", "public"]
}
+7
View File
@@ -0,0 +1,7 @@
import { defineConfig } from "vitest/config";
import { fileURLToPath } from "node:url";
export default defineConfig({
resolve: { alias: { "@": fileURLToPath(new URL("./", import.meta.url)) } },
test: { include: ["tests/**/*.test.ts", "lib/**/*.test.ts"] },
});