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
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Public application origin and exact OAuth callback
APP_ORIGIN=http://localhost:3000
GOOGLE_OAUTH_REDIRECT_URI=http://localhost:3000/api/auth/google/callback

# Google Cloud identifiers and server-side OAuth secret
GOOGLE_CLIENT_ID=replace-with-google-oauth-client-id
GOOGLE_CLIENT_SECRET=replace-with-google-oauth-client-secret
GOOGLE_API_KEY=replace-with-picker-api-key
GOOGLE_CLOUD_PROJECT_NUMBER=123456789012
ALLOWED_GOOGLE_EMAIL=owner@example.test

# Pooled PostgreSQL runtime connection (never use production for tests)
DATABASE_URL=postgresql://runtime-user:replace-with-password@localhost:5432/accura

# Generate independent values as documented in docs/anleitungen/produktions-setup.md
TOKEN_ENCRYPTION_KEY=replace-with-base64-encoded-32-byte-key
SESSION_SECRET=replace-with-at-least-32-random-bytes
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,42 @@ jobs:
- name: Run unit tests
run: npm test

postgres-tests:
name: PostgreSQL Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 10
services:
postgres:
image: postgres:17
env:
POSTGRES_DB: accura_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres -d accura_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_TEST_URL: postgresql://postgres:postgres@127.0.0.1:5432/accura_test
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run PostgreSQL integration tests
run: npm run test:postgres

build:
name: Production Build
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ pnpm-debug.log*
.DS_Store
Thumbs.db
.vercel
.env*
18 changes: 18 additions & 0 deletions api/_lib/database.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import postgres from 'postgres';

const databases = new Map<string, postgres.Sql>();

/** Returns one lazy PostgreSQL pool per connection URL in the current function instance. */
export function getDatabase(databaseUrl: string): postgres.Sql {
const existing = databases.get(databaseUrl);
if (existing) return existing;

const sql = postgres(databaseUrl, {
max: 1,
idle_timeout: 20,
connect_timeout: 10,
prepare: false,
});
databases.set(databaseUrl, sql);
return sql;
}
Loading
Loading