Slide 1

Slide 1 text

GETTING UP TO SPEED WITH DENO 01 SHODIPO AYOMIDE | CITYJS CONFERENCE LONDON, 2020 A JavaScript & TypeScript Runtime.

Slide 2

Slide 2 text

Shodipo Ayomide Senior Developer Advocate & Developer Program Manager - GitHub Star - Cloudinary Media Developer Expert - Community Evangelist GETTING UP TO SPEED WITH DENO 02

Slide 3

Slide 3 text

Deno is a Modern Secure runtime for JavaScript & TypeScript that runs on the V8 engine and built from the ground up in Rust. And supports TypeScript out of the box. 03 GETTING UP TO SPEED WITH DENO What is Deno

Slide 4

Slide 4 text

Deno is secured by default, it doesnt have access to your local network by default, unlike NodeJS which accesses everything. 04 GETTING UP TO SPEED WITH DENO What is Deno

Slide 5

Slide 5 text

Deno doesn’t have access to your C: drive by default for security reasons, unlike NodeJS which accesses everything. 05 GETTING UP TO SPEED WITH DENO What is Deno

Slide 6

Slide 6 text

GETTING UP TO SPEED WITH DENO Installation 06 Deno ships as a single executable with no dependencies, so there is nothing like deno_modules :)

Slide 7

Slide 7 text

GETTING UP TO SPEED WITH DENO Installation 07 Put in the specific comand into your terminal based on your operating system and get deno installed globally.

Slide 8

Slide 8 text

Deno allows us to host files on remote URL's and execute them from the URL in your terminal. 08 GETTING UP TO SPEED WITH DENO Deno Serve (Remote URL)

Slide 9

Slide 9 text

09 GETTING UP TO SPEED WITH DENO Deno Serve (Remote URL) It's as simple as running deno run and the url with the function we would like to execute in our terminal and we get a response.

Slide 10

Slide 10 text

The display would be console.logged into your terminal how it is seen below: 10 GETTING UP TO SPEED WITH DENO Deno Serve (Remote URL)

Slide 11

Slide 11 text

This is being console.logged into your terminal how it is seen below because that was what was instructed from the start: 11 GETTING UP TO SPEED WITH DENO Deno Serve (Remote URL)

Slide 12

Slide 12 text

After the installation, we are going to write a simple function to create a new server with a response of Hello World listening on port:8080 12 GETTING UP TO SPEED WITH DENO Deno Serve

Slide 13

Slide 13 text

13 GETTING UP TO SPEED WITH DENO Deno Serve Steps: - Create a new project folder called `deno-example` - Create a file called hello-world.ts - Write a simple function to serve hello world

Slide 14

Slide 14 text

14 GETTING UP TO SPEED WITH DENO Deno Serve We are importing a package from a URL and serving to a port:8000. For visibility reasons we are also going to console.log the localhost url so we can access our server. And lastly create a for await loop which we are going to send a hello world message to.

Slide 15

Slide 15 text

15 GETTING UP TO SPEED WITH DENO Deno Serve Deno dosen't have access to your local network "localhost" for security reasons, everytime you would like to execute a command you have to use a flag called:

Slide 16

Slide 16 text

16 GETTING UP TO SPEED WITH DENO Deno Serve Now to get our server running you have to initiate the deno in the terminal by running: The official comand to get deno running is `deno run`, we also added a network flag to give access to our local network and we also added a route to the specific file we would like to serve.

Slide 17

Slide 17 text

17 GETTING UP TO SPEED WITH DENO Deno Serve Once you hit enter, deno request's for your system's permission to allow or deny deno acces to your local network. Allow that.

Slide 18

Slide 18 text

Once the network has been allowed, it is served instantly to port:8080 as seen below. 18 GETTING UP TO SPEED WITH DENO Deno Serve

Slide 19

Slide 19 text

Click or open the http://localhost:8000/ host in your browser for your output and it should look like the below. 19 GETTING UP TO SPEED WITH DENO Deno Serve

Slide 20

Slide 20 text

20 Making an HTTP request in Deno GETTING UP TO SPEED WITH DENO We are getting some content using the fetch API and then console logging our response:

Slide 21

Slide 21 text

21 Making an HTTP request in Deno GETTING UP TO SPEED WITH DENO

Slide 22

Slide 22 text

22 Making an HTTP request in Deno GETTING UP TO SPEED WITH DENO

Slide 23

Slide 23 text

23 Making an HTTP request in Deno GETTING UP TO SPEED WITH DENO Now as you can see we are fetching some data from the regular example.com domain and it is giving us exactly what we want to avoid any bad code from coming in, deno is secured.

Slide 24

Slide 24 text

24 GETTING UP TO SPEED WITH DENO Deploying your Deno app on Vercel (ZEIT)

Slide 25

Slide 25 text

25 GETTING UP TO SPEED WITH DENO First you would create a folder called API and get our hello-world.ts file in there. Next, what we would like to get is the current version of Deno we are importing. Deploying a Deno app on Vercel (ZEIT)

Slide 26

Slide 26 text

26 GETTING UP TO SPEED WITH DENO Deploying a Deno app on Vercel (ZEIT)

Slide 27

Slide 27 text

27 GETTING UP TO SPEED WITH DENO Deploying a Deno app on Vercel (ZEIT) Next, In your root folder you create a file called `vercel.json` so we can create our vercel deno api function.

Slide 28

Slide 28 text

28 GETTING UP TO SPEED WITH DENO Deploying a Deno app on Vercel (ZEIT) Once you have gotten your vercel.json file setup, use the now --prod comand in your terminal to deploy your deno app to production on vercel.

Slide 29

Slide 29 text

29 GETTING UP TO SPEED WITH DENO Deploying a Deno app on Vercel (ZEIT) The next step is to visit the production URL and view what was deployed and route to your api dirctory & file to preview.

Slide 30

Slide 30 text

30 GETTING UP TO SPEED WITH DENO Resources GitHub Repo: https://github.com/Developerayo/deno-example Deploy URL: https://deno-api-example.vercel.app/api/hello-world Deno Website: https://deno.land/

Slide 31

Slide 31 text

Questions? Follow me on Twitter & GitHub @developerayo 31 GETTING UP TO SPEED WITH DENO Thank You! SHODIPO AYOMIDE | CITYJS CONFERENCE LONDON, 2020