Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lassejlv/postgres_http
Postgres => Rest API
https://github.com/lassejlv/postgres_http
Last synced: 27 days ago
JSON representation
Postgres => Rest API
- Host: GitHub
- URL: https://github.com/lassejlv/postgres_http
- Owner: lassejlv
- Created: 2024-12-09T11:27:29.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-12-11T08:24:51.000Z (about 1 month ago)
- Last Synced: 2024-12-17T03:35:35.500Z (27 days ago)
- Language: TypeScript
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Postgres HTTP
Turns your postgres db into an http server. Great for beginners or just small projects and testing.
[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/template/UYtPO2?referralCode=lasse)
## API reference
```bash
- POST /query
- body: { query: string, args: any[] }
- headers: { Authorization: Bearer }
- response: { rows: any[] }- GET /status
- headers: { Authorization: Bearer }
- response: { ok: boolean, ping: number }
```## Installation
```bash
git clone https://github.com/lassejlv/postgres_http.git
cd postgres_http
bun install
```## Generate an api key
```bash
openssl rand -base64 32
```## Required environment variables
```bash
PORT=
DATABASE_URL=
API_KEY=
ALLOW_DANGEROUS_SQL_COMMANDS=false # This will allow you to run DELETE or DROP or TRUNCATE commands. Set to true if you want to allow this.
```## Start the server
```bash
bun --watch index.ts
```## I cant run...
By default you cannot run: `DELETE, DROP, TRUNCATE`.
Update the env variable `ALLOW_DANGEROUS_SQL_COMMANDS` and set it to true if you wanna be doing that.## API key
You will find the api under the variables tab. It's randomly generated under creation.