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 dev

Redis can be disabled in gateway.yaml (redis.enabled: false) for a lightweight single-process development environment.


Development Commands

CommandPurpose
npm run devRuns the TypeScript entry point (src/index.ts) with file watching via tsx.
npm run buildType-checks and compiles src/ into the dist/ directory.
npm startRuns 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

  1. Let PostgreSQL Enforce Authorization: Application checks should never attempt to replace database-level access control. Always translate scopes to PostgreSQL roles.
  2. Fail Closed: If database identity, connection ownership, or transaction outcomes cannot be verified, fail closed and surface clear error codes.
  3. Bound Everything: Always bound memory, statement counts, queue sizes, concurrency, and connection pools. Unbounded queues cause memory leaks and denial of service.
  4. Never Leak Secrets: Never log raw API keys, passwords, hashes, secret seeds, or bound parameter values.
  5. 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.yaml and openapi.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

  1. Keep pull requests focused on a single feature or bug fix.
  2. Run npm run build to verify clean compilation with zero TypeScript errors.
  3. Manually verify authentication, permission checks, and edge cases against a disposable PostgreSQL database.
  4. Call out any database migration, backward compatibility, or security considerations in your PR description.
Copyright © 2026