Skip to content

Transform Your PostgreSQL Database into a Production-Ready, Blazing-Fast Standalone REST API Web Server With Static Type Checking and Automatic Code Generation

License

Notifications You must be signed in to change notification settings

NpgsqlRest/NpgsqlRest

Repository files navigation

NpgsqlRest

Build, Test, Publish and Release License GitHub Stars GitHub Forks

Automatic REST API Server for PostgreSQL

Transform your PostgreSQL database into a production-ready REST API server with automatic TypeScript code generation and end-to-end type safety.

Documentation | Getting Started | Configuration Reference | Annotation Guide

Key Features

  • Instant API Generation - Automatically creates REST endpoints from PostgreSQL functions, procedures, tables, and views
  • Declarative Configuration - Configure endpoints directly in your database using comment annotations
  • TypeScript Code Generation - Auto-generate type-safe frontend code with full static type checking
  • Native Executables - AOT-compiled binaries with zero dependencies and instant startup
  • RESTful Path Parameters - Define routes like /products/{id} with parameters extracted from URL paths
  • Reverse Proxy Endpoints - Forward requests to upstream services with passthrough or transform modes
  • HTTP Custom Types - Enable PostgreSQL functions to call external APIs via annotated composite types
  • Enterprise Ready - Authentication, authorization, rate limiting, caching, SSE streaming, OpenAPI 3.0, and more

Quick Start

1. Annotate a PostgreSQL Function

create function hello(_name text)
returns text
language sql as $$
select 'Hello, ' || _name
$$;

comment on function hello(text) is 'HTTP GET /hello';

2. Configure Connection

Create appsettings.json:

{
  "ConnectionStrings": {
    "Default": "Host=localhost;Port=5432;Database=my_db;Username=postgres;Password=postgres"
  }
}

3. Run

# Download from releases, or:
npm i npgsqlrest && npx npgsqlrest

# Or with Docker:
docker run -p 8080:8080 -v ./appsettings.json:/app/appsettings.json vbilopav/npgsqlrest:latest

Your API is now live at http://localhost:8080/hello?name=World

Installation Options

Method Command
NPM npm i npgsqlrest
Docker docker pull vbilopav/npgsqlrest:latest
Direct Download Releases
.NET Library dotnet add package NpgsqlRest

Requirements

  • PostgreSQL >= 13
  • No runtime dependencies for native executables

Documentation

For complete documentation including configuration options, authentication setup, TypeScript generation, and more, visit npgsqlrest.github.io

Contributing

Contributions are welcome. Please open a pull request with a description of your changes.

License

MIT License

About

Transform Your PostgreSQL Database into a Production-Ready, Blazing-Fast Standalone REST API Web Server With Static Type Checking and Automatic Code Generation

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages