BUILDING WITH JAMSTACK WRANGLING APIS AND UIS
PHIL HAWKSWORTH @PHILHAWKSWORTH
Slide 18
k c a t s m a j
Fast and secure sites and apps delivered by pre-rendering files and serving them directly from a CDN, removing the requirement to manage or run web servers.
https://jamstack.org
Slide 19
ASK FOR STUFF GET STUFF
Slide 20
“VIEWING” SITES &
“DOING” SITES
Slide 21
ASK FOR STUFF GET STUFF
DO ALL SORTS OF STUFF
Slide 22
MONOLITHS ONE CHOICE FOR ALL DISCIPLINES
Slide 23
https://unsplash.com/photos/KzGhmrQmB6I
Slide 24
Slide 25
SEPARATION OF CONCERNS
Slide 26
k c a t s jam MARKUP
JAVASCRIPT
API
AS MUCH AS POSSIBLE, GENERATED IN ADVANCE
USED AS A PROGRESSIVE ENHANCEMENT
IN THE BROWSER OR ELSEWHERE
HOW ARE APIS AND UIS COUPLED?
URL / SIGNATURE / RESPONSE
Slide 33
EXAMPLE
Slide 34
FINDTHAT.AT/CATCOUTURE
EXAMPLE
Slide 35
{ “prod-cat-outfit-lion”: { “name”: “Cat lion mane costume”, “rrp”: “100.00”, “image”: “product-cat-lion.jpg”, “description”: “Dress your cat up as a lion and make it hate you while it looks cool.” }, … } inventory.json
Slide 36
EXAMPLE
Slide 37
API
USER INTERFACE
Slide 38
const productViews = document.querySelectorAll(‘.product’); productViews.forEach(element =>” { fetch(/api/stock/${element.dataset.productId}) .then(response =>” response.json()) .then(data =>” { // update the UI based on the // levels of available stock });
})
shop.js
Slide 39
COUPLING — API ENDPOINT
Slide 40
API
USER INTERFACE
Slide 41
API
USER INTERFACE
Slide 42
API
DECOUPLE WITH A PROXY
USER INTERFACE
Slide 43
[[redirects]] from = “/api/stock/:id” to = “/.netlify/functions/stock?productId=:id”
netlify.toml
Slide 44
[[redirects]] from = “/api/stock/:id” to = “https://other.api.com/stock?productId=:id”
netlify.toml
Slide 45
HOW ARE APIS AND UIS COUPLED?
URL / SIGNATURE / RESPONSE
HOW ARE APIS AND UIS COUPLED?
URL / SIGNATURE / RESPONSE
Slide 57
WRAPPING UP
Slide 58
LINES AND BOXES
Slide 59
STATIC FIRST ENHANCING IF REQUIRED
Slide 60
KEEP COUPLING LOOSE
Slide 61
THE API ECONOMY IS BOOMING
Slide 62
JAMSTACK & SERVERLESS ARE BEST FRIENDS
Slide 63
FINDTHAT.AT/LOLLY
Slide 64
FINDTHAT.AT/COMMENTS
Slide 65
FINDTHAT.AT/ELEVENTYONE
Slide 66
BOOK - MODERN WEB DEVELOPMENT ON THE JAMSTACK findthat.at/jamstackbook
FREE CODE CAMP VIDEO findthat.at/jamstack/fcc
JAMSTACK WHITEPAPER findthat.at/jamstack-whitepaper
JAMSTACK COMMENTS EXAMPLE findthat.at/comments