[breizhcamp, format 15min] une api rest et graphql sans code grâce à postgrest, sub0 et...
TRANSCRIPT
![Page 1: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/1.jpg)
Une API REST sans code grâce à Postgrest, Sub0 et PostgreSQL
![Page 2: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/2.jpg)
![Page 3: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/3.jpg)
François-Guillaume Ribreau
—
![Page 4: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/4.jpg)
François-Guillaume Ribreau
—Ex-Bringr cofounder & CTO
![Page 5: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/5.jpg)
François-Guillaume Ribreau
—Ex-Bringr cofounder & CTO
Ex-Architect @iAdvize
![Page 6: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/6.jpg)
François-Guillaume Ribreau
—Ex-Bringr cofounder & CTO
Ex-Architect @iAdvizeArchitect & Head of development @Ouest-France
![Page 7: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/7.jpg)
François-Guillaume Ribreau
—Ex-Bringr cofounder & CTO
Ex-Architect @iAdvizeArchitect & Head of development @Ouest-France
🌟 Founded @imagecharts @Redsmin @mailpopin
![Page 8: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/8.jpg)
François-Guillaume Ribreau
—Ex-Bringr cofounder & CTO
Ex-Architect @iAdvizeArchitect & Head of development @Ouest-France
🌟 Founded @imagecharts @Redsmin @mailpopin
🚀 Trainer @EPSI_Nantes @UnivNantes
![Page 9: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/9.jpg)
François-Guillaume Ribreau
—Ex-Bringr cofounder & CTO
Ex-Architect @iAdvizeArchitect & Head of development @Ouest-France
🌟 Founded @imagecharts @Redsmin @mailpopin
🚀 Trainer @EPSI_Nantes @UnivNantes📢 Twitter/Github: @FGRibreau
![Page 10: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/10.jpg)
![Page 11: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/11.jpg)
API?
![Page 12: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/12.jpg)
API?
Persistence API?
![Page 13: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/13.jpg)
Single Source of Truth?
API?
Persistence API?
![Page 14: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/14.jpg)
Single Source of Truth?
DRY?
API?
Persistence API?
![Page 15: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/15.jpg)
3-tier
Database
API
Frontend
![Page 16: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/16.jpg)
3-tier
Database(Tables/Views
Schema)
API(Models / ORM)
Front
![Page 17: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/17.jpg)
Validation
Database(Schema (constraint))
API(Models / ORM
(validation))
Front(validation)
![Page 18: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/18.jpg)
Relation
Database(Schema (referential
integrity))
API(Models / ORM
(relations))
Front
![Page 19: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/19.jpg)
Authorization
Database(Users, roles,
policies)
API(Authorization middleware)
Front
![Page 20: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/20.jpg)
Etc… 🕰
Database…
API…
Front
![Page 21: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/21.jpg)
API
DB
• HTTP request handling • Authentication• Authorization• Request Parsing • Request Validation • Database Communication • Database Response Handling • HTTP Response Building
Persistence API
your job
![Page 22: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/22.jpg)
API
SQLHTTP DB
• HTTP request handling • Authentication• Authorization• Request Parsing • Request Validation • Database Communication • Database Response Handling • HTTP Response Building
Persistence API
your job
![Page 23: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/23.jpg)
API
SQLHTTP DB
Persistence API
TL;DR: HTTP <-> SQL mapping
… with a lot of space for potential mistakes. your job
![Page 24: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/24.jpg)
Postgrest DB
Persistence API
your job#SSoT #DRY
![Page 25: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/25.jpg)
Are we serious?
![Page 26: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/26.jpg)
Are we serious?
![Page 27: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/27.jpg)
Postgrest DB
Persistence API
your job#SSoT #DRY
schema
![Page 28: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/28.jpg)
Postgrest
Read / Write requests
(read) GET /projects (read) GET /account
(write) POST /rpc/signUp (write) POST /rpc/logIn
![Page 29: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/29.jpg)
How do you manage projection, filtering, ordering?
![Page 30: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/30.jpg)
GET /people?age=gte.18&isStudent=is.true
How do you manage projection, filtering, ordering?
![Page 31: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/31.jpg)
GET /people?age=gte.18&isStudent=is.true
GET /people?select=age::text,height,weight
How do you manage projection, filtering, ordering?
![Page 32: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/32.jpg)
GET /people?age=gte.18&isStudent=is.true
GET /people?select=age::text,height,weight
GET /stuff?metadata->a->>b=eq.2
How do you manage projection, filtering, ordering?
![Page 33: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/33.jpg)
GET /people?age=gte.18&isStudent=is.true
GET /people?select=age::text,height,weight
GET /stuff?metadata->a->>b=eq.2
GET /projects?select=id,name,tasks{id,name}
&order=id.asc&tasks.order=name.asc
How do you manage projection, filtering, ordering?
![Page 34: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/34.jpg)
How do you manage versioning?
![Page 35: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/35.jpg)
How do you manage versioning?
public private
![Page 36: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/36.jpg)
How do you manage versioning?
public private
authentication schema
i18n schema
app schema
….
schema
![Page 37: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/37.jpg)
How do you manage versioning?
public private
v1_0 schema authentication schema
i18n schema
app schema
….
view schemastoredfn
projects signIn signUp
![Page 38: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/38.jpg)
How do you manage versioning?
public private
v1_0 schema
v2_0 schema
authentication schema
i18n schema
app schema
….
view schemastoredfn
projects signIn signUp
projects logIn signUp
![Page 39: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/39.jpg)
How do you manage authentication?
![Page 40: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/40.jpg)
How do you manage authentication?
![Page 41: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/41.jpg)
How do you manage authorization?
![Page 42: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/42.jpg)
How do you manage authorization?
CREATE ROLE authenticator NOINHERIT LOGIN; CREATE ROLE anonymous; CREATE ROLE authenticated_user; GRANT anonymous, authenticated_user TO authenticator;
![Page 43: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/43.jpg)
How do you manage authorization?
![Page 44: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/44.jpg)
How do you manage authorization?
Row Level Security (PG 9.5+)
![Page 45: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/45.jpg)
How do you manage authorization?
Row Level Security (PG 9.5+)ALTER TABLE app.project ENABLE ROW LEVEL SECURITY;
CREATE POLICY user_can_only_access_its_own_project on app.project — Any rows for which the expression returns false or null will not be visible to the user (in a SELECT), and will not be available for modification (in an UPDATE or DELETE)
using (user_id = current_setting('request.jwt.claim.user_id'))
![Page 46: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/46.jpg)
How do you manage authorization?
Row Level Security (PG 9.5+)ALTER TABLE app.project ENABLE ROW LEVEL SECURITY;
CREATE POLICY user_can_only_access_its_own_project on app.project — Any rows for which the expression returns false or null will not be visible to the user (in a SELECT), and will not be available for modification (in an UPDATE or DELETE)
using (user_id = current_setting('request.jwt.claim.user_id'))
2 lines of SQLReliable security model (closed by default)
Declarative Expressive
![Page 47: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/47.jpg)
How do you manage emails/3rd parties?
http://bit.ly/2oNbaKy
![Page 48: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/48.jpg)
How do you manage emails/3rd parties?pg_notify (PG 9.2+)
http://bit.ly/2oNbaKy
![Page 49: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/49.jpg)
How do you manage documentation?
![Page 50: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/50.jpg)
How do you manage documentation?
OpenAPI (Swagger) formatautomatically extracted from schema
![Page 51: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/51.jpg)
How do you manage code-reviews, tests, migrations?
Pivotal/trilogy pg_tag pg_unit pg_unit2
![Page 52: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/52.jpg)
How do you manage code-reviews, tests, migrations?
It’s just SQL.
Pivotal/trilogy pg_tag pg_unit pg_unit2
![Page 53: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/53.jpg)
One more thing
![Page 54: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/54.jpg)
PostgraphQL A GraphQL API created by reflection over a PostgreSQL schema. (NodeJS)
![Page 56: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/56.jpg)
Free plans for Redis administration & monitoring
at redsmin.com
Questions?
@FGRibreau
No more server-side rendering pain, 1 url = 1 chart
image-charts.com
![Page 57: [BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgREST, sub0 et PostgreSQL](https://reader031.vdocuments.mx/reader031/viewer/2022022415/5a6d49597f8b9af2418b520d/html5/thumbnails/57.jpg)
Free plans for Redis administration & monitoring
at redsmin.com
We are looking for Front-end Developers
twitter.com/iadvizetech
Questions?
@FGRibreau
No more server-side rendering pain, 1 url = 1 chart
image-charts.com