Registry / database / npgsqlrest

npgsqlrest

JSON →
library3.16.3jsnpmunverified

Automatic REST API server for PostgreSQL databases that generates REST endpoints from database functions, procedures, tables, and views. Version 3.16.3 (current stable) is actively developed with monthly releases. Key differentiators include AOT-compiled native executables for performance (claimed 6x faster than PostgREST), TypeScript client code generation with end-to-end type safety, declarative configuration via SQL comment annotations, and support for authentication (cookie, JWT, OAuth), authorization, caching, rate limiting, SSE, and OpenAPI 3.0 documentation. Unlike PostgREST or Supabase, NpgsqlRest is a Node.js/npm package that bundles a native binary for Windows, macOS, and Linux.

npm install npgsqlrest
INSTALL
IMPORT
SIG · NPGSQLREST
N
npgsqlrest
databasejavascriptv3.16.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NpgsqlRest (CLI)
npx npgsqlrest
npm install -g npgsqlrest && npgsqlrest
Use npx to run without global install. The npm package downloads a native binary; no JavaScript import is used.
Auto-generated TypeScript client
Generated file like ./src/api/{0}Api.ts (import { publicHelloWorld } from './src/api/publicApi')
import npgsqlrest from 'npgsqlrest'
The generated client is per-database; you do not import from the package itself.
Configuration (appsettings.json)
Create appsettings.json and run npx npgsqlrest
passing JSON via CLI argument without file
Config file is in JSON format; CLI supports override flags (e.g., --urls).

Creates a PostgreSQL function with HTTP annotation, configures connection, runs server, and verifies REST endpoint.

// 1. Create a PostgreSQL function with annotation // CREATE FUNCTION hello_world() RETURNS text LANGUAGE sql AS $$ SELECT 'Hello World' $$; // COMMENT ON FUNCTION hello_world() IS 'HTTP GET /hello'; // 2. Create appsettings.json // { // "ConnectionStrings": { // "Default": "Host=localhost;Port=5432;Database=mydb;Username=postgres;Password=postgres" // } // } // 3. Run the server // npx npgsqlrest // 4. Test endpoint // curl http://localhost:8080/hello // => "Hello World"
Debug
Known issues
breakingThe package downloads a native binary; it may not be available for all platforms or architectures (e.g., ARM Linux, BSD, 32-bit).
fix
Check GitHub releases for native binaries; consider using Docker or building from source.
affects: >=3.0
gotchaThe package requires a PostgreSQL database with functions annotated via COMMENT ON FUNCTION IS 'HTTP GET /path'. Without annotations, no endpoints are created.
fix
Add SQL comment annotations to functions according to documentation.
affects: >=1.0
deprecatedOld configuration files might use a different schema (e.g., without 'NpgsqlRest' section).
fix
Migrate to version 3 configuration format: wrap NpgsqlRest-specific options under 'NpgsqlRest' key.
affects: <3.0
gotchaThe CLI uses .NET configuration; some settings are only available via JSON file, not CLI flags.
fix
Refer to documentation for all configurable options; use appsettings.json for full control.
affects: >=3.0
Errors
Common errors & fixes
Could not execute because the application was not found or a matching command is not installed.
The native binary is not downloaded properly or platform support is missing.
fix
Ensure npm install completed without errors; try reinstalling: npm uninstall npgsqlrest && npm install npgsqlrest. If on ARM, use Docker.
NpgsqlRest server failed to start: 'Connection refused' or 'FATAL: database does not exist'
Invalid connection string or PostgreSQL not running/accessible.
fix
Check PostgreSQL is running; verify connection string in appsettings.json; ensure network access.
GET /hello 404 Not Found
No PostgreSQL function with annotation matching the URL path was created.
fix
Verify the function exists and has correct comment annotation: COMMENT ON FUNCTION hello_world() IS 'HTTP GET /hello';
MissingMethodException: Method not found: 'Void NpgsqlRest.Configuration.set_SomeOption'
Incompatible configuration file schema (e.g., from older version).
fix
Update appsettings.json to match the configuration schema for version 3. See documentation.
Upgrade
Version history
3.16.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
npgsqlrest — npm install npgsqlrest · libregistry