Lade...
 

nobackend for real: PostgreSQL to REST with PostgREST!

mathiasp Dienstag Januar 12, 2016

I sort of liked the idea of nobackend, but hated it's js-orientedness.

I think a generic backend should talk generic APIs, and do not want to be presented with some javascript mubo jumbo. Esp. since I prefer clojurescript ;)

Enter PostgREST: a simple (?) no-nonsense PostgreSQL to REST solution.

And it's breathtakingly simple: download the postgres binary, copy it somewhere on your server, probably somewhere in your path, and then call it with:

postgrest postgres://user:pass@host:port/db [flags]


that's it. Your PostgreSQL server is now available via http, by default on port 3000.

Simple, isn't it?

GET /


will give you some JSON with the available tables, and (you guessed it):

GET /myinterestingtable


gets you the table contents as JSON

[{"vorname":"Mathias","nachname":"Picker",
"email":"Mathias.Picker@virtualearth.de","postleitzahl":null,
"stadt":null,"strae":null,
"unternehmen":null,"berufsbezeichnung":null,
"telefon_geschaeftlich":null}]


PostgREST supports JWT token security, full insert, update, delete capabilities, calling database functions, follows foreign key relations: you name it, it has it. The author even describes a very nice and flexible user management system, working only with PostgreSQL tables, functions and triggers.

Very, very nice. Blazing fast. I warmly recommend it!

Sad point: I can't compile it on FreeBSD; I'm currently running the linux version.