跳至正文
Wener Notes

PostgREST

约 1 分钟阅读
    • MIT, Haskell
    • 功能: 将现有的 PostgreSQL 数据库直接转换为 RESTful API。
    • 特点: 高性能,无依懒,基于数据库 Schema 自动生成 API。

Quick Start (Docker)

bash
# 1. Start PostgREST
docker run --rm --net=host \
  -e PGRST_DB_URI="postgres://postgres:password@localhost/postgres" \
  -e PGRST_DB_ANON_ROLE="postgres" \
  postgrest/postgrest

# 2. Config via file
docker run --rm -v $PWD/postgrest.conf:/etc/postgrest.conf \
  postgrest/postgrest /etc/postgrest.conf

Configuration (postgrest.conf):

ini
db-uri = "postgres://postgres:password@localhost/postgres"
db-schema = "public"
db-anon-role = "web_anon"
db-pool = 10

Tools

  • Swagger UI
    bash
    docker run --rm -p 8081:8080 -e API_URL=http://localhost:3000 swaggerapi/swagger-ui

Alternatives

关联信息

反向链接、本文链接的其他页面和外部资料。

参考资料

GitHub2 条
最近更新commit 906e816编辑