Turning the Static Dynamic

A presentation at JAMstack Boston in April 2019 in Boston, MA, USA by Divya

Slide 1

Slide 1

Turning the Static Dynamic Divya Sasidharan

Slide 2

Slide 2

!

Slide 3

Slide 3

Divya Sasidharan

Slide 4

Slide 4

@shortdiv

Slide 5

Slide 5

What is “Static“?

Slide 6

Slide 6

Static Dynamic

Slide 7

Slide 7

vs

Slide 8

Slide 8

secure fast flexible scalable

Slide 9

Slide 9

Being “Static“

Slide 10

Slide 10

Slide 11

Slide 11

JAMStack

Slide 12

Slide 12

Slide 13

Slide 13

JAMStack JavaScript API Markup

Slide 14

Slide 14

Build

Slide 15

Slide 15

Build Markup

Slide 16

Slide 16

Build Markup JavaScript

Slide 17

Slide 17

Build Markup Website! JavaScript

Slide 18

Slide 18

Build Markup APIs Website! JavaScript

Slide 19

Slide 19

Build Markup APIs Website! JavaScript

Slide 20

Slide 20

Build API API Markup Website! API API JavaScript

Slide 21

Slide 21

“Decoupled”

Slide 22

Slide 22

Going “Dynamic“

Slide 23

Slide 23

Tools of the Trade Build Automation Event Triggers APIs Serverless

Slide 24

Slide 24

Build Automation

Slide 25

Slide 25

Build Markup JavaScript

Slide 26

Slide 26

[build] command=”npm run build” publish=”public”

Slide 27

Slide 27

https://setyourwatchby.netlify.com/America/New_York

Slide 28

Slide 28

Event Triggers

Slide 29

Slide 29

if this then that

Slide 30

Slide 30

Event Triggers Form Submissions Build/Deploy Events Split Test Events Auth Events Form Submissions Content Updates Git Activity Event Hooks

Slide 31

Slide 31

Demo Time!

Slide 32

Slide 32

APIs

Slide 33

Slide 33

ecosystem \ ˈē-kō-ˌsi-stəm

Slide 34

Slide 34

Form Handling Search Push Notifications Authentication Database Static Hosting Payments Media Storage Headless CMS Monitoring FAAS Providers ecosystem \ ˈē-kō-ˌsi-stəm

Slide 35

Slide 35

thepowerofserverless.info

Slide 36

Slide 36

Serverless

Slide 37

Slide 37

Functions as a Service

Slide 38

Slide 38

Slide 39

Slide 39

Demo Time!

Slide 40

Slide 40

Demo Time!

Slide 41

Slide 41

Slide 42

Slide 42

exports.handler = function(event, context, callback) { const data = JSON.parse(event.body); const { user } = data; console.log(user.email); console.log(“identity yourself”, context.clientContext.identity); const validateUser = email => { if (email.split(“@”)[1] === “netlify.com”) { return [“editor”]; } else { return [“visitor”]; } }; const roles = validateUser(user.email); const responseBody = { app_metadata: { roles, my_user_info: “this is user info that the user can’t change from the UI” }, user_metadata: { …user.user_metadata, custom_data_from_function: “hurray this is some extra metadata” } }; }; callback(null, { statusCode: 200, body: JSON.stringify(responseBody) });

Slide 43

Slide 43

exports.handler = function(event, context, callback) { const data = JSON.parse(event.body); const { user } = data; console.log(user.email); console.log(“identity yourself”, context.clientContext.identity); const validateUser = email => { if (email.split(“@”)[1] === “netlify.com”) { return [“editor”]; } else { return [“visitor”]; } }; const roles = validateUser(user.email); const responseBody = { app_metadata: { roles, my_user_info: “this is user info that the user can’t change from the UI” }, user_metadata: { …user.user_metadata, custom_data_from_function: “hurray this is some extra metadata” } }; }; callback(null, { statusCode: 200, body: JSON.stringify(responseBody) });

Slide 44

Slide 44

exports.handler = function(event, context, callback) { const data = JSON.parse(event.body); const { user } = data; console.log(user.email); console.log(“identity yourself”, context.clientContext.identity); const validateUser = email => { if (email.split(“@”)[1] === “netlify.com”) { return [“editor”]; } else { return [“visitor”]; } }; const roles = validateUser(user.email); const responseBody = { app_metadata: { roles, my_user_info: “this is user info that the user can’t change from the UI” }, user_metadata: { …user.user_metadata, custom_data_from_function: “hurray this is some extra metadata” } }; }; callback(null, { statusCode: 200, body: JSON.stringify(responseBody) });

Slide 45

Slide 45

exports.handler = function(event, context, callback) { const data = JSON.parse(event.body); const { user } = data; console.log(user.email); console.log(“identity yourself”, context.clientContext.identity); const validateUser = email => { if (email.split(“@”)[1] === “netlify.com”) { return [“editor”]; } else { return [“visitor”]; } }; const roles = validateUser(user.email); const responseBody = { app_metadata: { roles, my_user_info: “this is user info that the user can’t change from the UI” }, user_metadata: { …user.user_metadata, custom_data_from_function: “hurray this is some extra metadata” } }; }; callback(null, { statusCode: 200, body: JSON.stringify(responseBody) });

Slide 46

Slide 46

exports.handler = function(event, context, callback) { const data = JSON.parse(event.body); const { user } = data; console.log(user.email); console.log(“identity yourself”, context.clientContext.identity); const validateUser = email => { if (email.split(“@”)[1] === “netlify.com”) { return [“editor”]; } else { return [“visitor”]; } }; const roles = validateUser(user.email); const responseBody = { app_metadata: { roles, my_user_info: “this is user info that the user can’t change from the UI” }, user_metadata: { …user.user_metadata, custom_data_from_function: “hurray this is some extra metadata” } }; }; callback(null, { statusCode: 200, body: JSON.stringify(responseBody) });

Slide 47

Slide 47

{ }; app_metadata: { roles, …user.app_metadata, my_user_info: “some user info” }, user_metadata: { …user.user_metadata, custom_data_from_function: “hurray extra metadata!” }

Slide 48

Slide 48

{ }; app_metadata: { roles, …user.app_metadata, my_user_info: “some user info” }, user_metadata: { …user.user_metadata, custom_data_from_function: “hurray extra metadata!” }

Slide 49

Slide 49

JAMstack Boston Divya Sasidharan @shortdiv