Operations & Security
Development & Contributing
Local development environment, project layout, design principles, and contribution workflow.
Development & Contributing Guide
Contributions to HTTP PostgreSQL Gateway should preserve its security boundaries, persistent storage formats, API schemas, and operator documentation.
Local Development Setup
# 1. Clone repository
git clone https://github.com/http-postgres/http-postgres.git
cd http-postgres
# 2. Install dependencies
npm ci
# 3. Configure environment
cp .env.example .env
# 4. Start TypeScript development server with hot-reload
npm run devRedis can be disabled in gateway.yaml (redis.enabled: false) for a lightweight single-process development environment.
Development Commands
| Command | Purpose |
|---|---|
npm run dev | Runs the TypeScript entry point (src/index.ts) with file watching via tsx. |
npm run build | Type-checks and compiles src/ into the dist/ directory. |
npm start | Runs the compiled production application from dist/index.js. |
Source Code Layout
src/
├── config/ # gateway.yaml loader, validation schemas, and privilege maps
├── middleware/ # Authentication, rate limiting, and request IP hooks
├── plugins/ # Fastify plugins, error handlers, and shutdown hooks
├── routes/ # Route definitions for admin, query, and transaction APIs
└── utils/ # PostgreSQL pool manager, JsonDB, analytics worker, bootstrap
docs/ # Markdown operator and user documentation
gateway.yaml # Runtime YAML configuration file
openapi.yaml # OpenAPI 3.0 API specification (YAML)
openapi.json # OpenAPI 3.0 API specification (JSON)src/index.ts: Process entry point; handles startup sequencing and graceful shutdown signals (SIGINT,SIGTERM).src/app.ts: Assembles Fastify instance, registers plugins, and configures error handling.src/routes/index.ts: Wires persistent storage, analytics buffers, and connection pools to route groups.
Architectural Design Principles
- Let PostgreSQL Enforce Authorization: Application checks should never attempt to replace database-level access control. Always translate scopes to PostgreSQL roles.
- Fail Closed: If database identity, connection ownership, or transaction outcomes cannot be verified, fail closed and surface clear error codes.
- Bound Everything: Always bound memory, statement counts, queue sizes, concurrency, and connection pools. Unbounded queues cause memory leaks and denial of service.
- Never Leak Secrets: Never log raw API keys, passwords, hashes, secret seeds, or bound parameter values.
- Lossless Conversions: Preserve numeric precision and timestamps by default.
OpenAPI Synchronization
The repository maintains both openapi.yaml and openapi.json.
When modifying an HTTP endpoint:
- Update method, path, headers, request schema, and response envelopes in both
openapi.yamlandopenapi.json. - Update the relevant markdown guide in
docs/and this documentation portal. - Verify status codes, error codes, and parameter types match the code implementation.
Pull Request Guidelines
- Keep pull requests focused on a single feature or bug fix.
- Run
npm run buildto verify clean compilation with zero TypeScript errors. - Manually verify authentication, permission checks, and edge cases against a disposable PostgreSQL database.
- Call out any database migration, backward compatibility, or security considerations in your PR description.
