Skip to content

NpgsqlRestAutomatic PostgreSQL Web Server

Create professional, high-performance HTTP REST APIs for PostgreSQL databases in minutes. Write plain SQL files โ€” get REST endpoints automatically.

NpgsqlRest Architecture - PostgreSQL at the center with automatic REST API, TypeScript generation, authentication, caching, and more

Clean PostgreSQL Architecture - PostgreSQL First Architecture - PostgreSQL Driven Architecture

  • โœ“ Schema as contract โ€” SQL files, functions, tables, and views become REST endpoints
  • โœ“ SQL comments as config โ€” Routes, auth, caching declared where the logic lives
  • โœ“ Types flow outward โ€” PostgreSQL types generate TypeScript clients automatically
  • โœ“ No middle tier โ€” No ORM mismatch, no N+1 queries, no boilerplate

Declarative Annotations โ€‹

Simple comment annotations turn SQL files and PostgreSQL functions into fully-featured REST endpoints.

SQL File

sql
/*
HTTP GET /users/
@authorize admin, user
@cached
@cache_expires_in 30sec
@timeout 5min
@table_format = excel
@excel_file_name = users.xlsx
*/
select id, name, email, role
from users
where $1 is null or department_id = $1;

PostgreSQL Function

sql
create or replace function api.get_users(
  _department_id int
)
returns table (id int, name text, email text, role text)
language sql
begin atomic;
select id, name, email, role
from users
where
  _department_id is null
  or department_id = _department_id;
end;

comment on function api.get_users(int) is '
HTTP GET /users/
@authorize admin, user
@cached
@cache_expires_in 30sec
@timeout 10sec
@retry_strategy aggressive
@rate_limiter_policy authenticated_limit
@tsclient_module = users
';

Blog โ€‹


Build, Test, Publish and ReleaseLicenseGitHub StarsGitHub ForksCrafted with Claude
โค๏ธ Support this project: Patreon ยท Buy Me a Coffee
Released under the MIT License.
Copyright ยฉ 2024-2026 VB Consulting