Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting up to Speed with Deno

Getting up to Speed with Deno

In this talk, I presented of the new JavaScript & TypeScript Runtime called Deno the advantages like Security by Default, TypeScript first-class language, ES Modules, Distributed Package Management, Top-Level Await, Standard Library, and more.

GitHub Repo: https://github.com/Developerayo/deno-example

Deploy URL: https://deno-api-example.vercel.app/api/hello-world

Deno Website: https://deno.land/

Shodipo Ayomide

September 14, 2020
Tweet

More Decks by Shodipo Ayomide

Other Decks in Technology

Transcript

  1. GETTING UP TO SPEED WITH DENO 01 SHODIPO AYOMIDE |

    CITYJS CONFERENCE LONDON, 2020 A JavaScript & TypeScript Runtime.
  2. Shodipo Ayomide Senior Developer Advocate & Developer Program Manager -

    GitHub Star - Cloudinary Media Developer Expert - Community Evangelist GETTING UP TO SPEED WITH DENO 02
  3. 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
  4. 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
  5. 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
  6. GETTING UP TO SPEED WITH DENO Installation 06 Deno ships

    as a single executable with no dependencies, so there is nothing like deno_modules :)
  7. 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.
  8. 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)
  9. 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.
  10. 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)
  11. 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)
  12. 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
  13. 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
  14. 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.
  15. 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:
  16. 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.
  17. 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.
  18. 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
  19. 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
  20. 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:
  21. 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.
  22. 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)
  23. 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.
  24. 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.
  25. 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.
  26. 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/
  27. Questions? Follow me on Twitter & GitHub @developerayo 31 GETTING

    UP TO SPEED WITH DENO Thank You! SHODIPO AYOMIDE | CITYJS CONFERENCE LONDON, 2020