Microsoft
Course Description
Take a first look at Deno, the new command-line runtime for JavaScript. It takes a fundamentally different approach to run JavaScript on the server based on the lessons learned from Node.js. Things like being secure by default, being built on TypeScript, as well as a fresh take on managing dependencies and shipping your apps. Deno is a JavaScript environment rethought from the ground up!
This course and others like it are available as part of our Frontend Masters video subscription.
Preview
CloseCourse Details
Published: March 16, 2021
Topics
Learn Straight from the Experts Who Shape the Modern Web
Your Path to Senior Developer and Beyond
- 200+ In-depth courses
- 18 Learning Paths
- Industry Leading Experts
- Live Interactive Workshops
Table of Contents
Introduction
Section Duration: 53 minutes
- Burke Holland introduces the course and gives some personal background details.
- Burke discusses the course exercises, how to navigate the course files, and how to use a remote containers extension to open the Deno exercises without installing Deno. Why Deno was created is also covered in this segment.
- Burke discusses Deno being optimized as a secure runtime environment to try and help avoid malicious packages and how the Node environment is exploited by hackers using type squatting.
- Burke discusses how Deno handles dependencies, the cost of npm being the central package repository for Node, and demonstrates the amount of dependencies being used in common libraries.
- Burke explains the benefits and drawbacks of strongly typed languages and the improved tooling experience with Deno's TypeScript-first environment. How Deno avoids initializing projects in JavaScript is also discussed in this segment.
Setup
Section Duration: 46 minutes
- Burke installs Deno, briefly demonstrates running JavaScript in the Deno REPL, and discusses the native bindings of Deno being rooted in Rust. The performance of Deno and other environments is also briefly looked at.
- Burke introduces the Deno tooling extension and walks through how to enable it even though Deno isn't enabled in the global user settings in VS code.
- Burke live codes a "Hello World" project using TypeScript and JavaScript and walks through the file structure that Deno pulls from the local machine. Deno will execute TypeScript and JavaScript, though most examples involving Deno are written in TypeScript.
- Burke discusses executing remote scripts using a URL in Deno and looks into operations found on the Deno object. The Deno object replacements for commonly used Node concepts including args, env, and _dirname are also covered in this segment.
- Burke talks about some interesting arguments that can be passed to the Deno CLI including a built-in formatting tool and explains how to pass in arguments to the Deno CLI to avoid errors. Deno commonly uses the built-in watcher using --unstable and --watch. Passing in watcher flags incorrectly will cause errors.
- Burke discusses multiple methods of debugging in Deno including using --inspect, Edge and Chrome browser dev tools, and VS Code. Deno can have a debugger attached in VS code with a configured launch.json file.
Thinking Like a Browser
Section Duration: 32 minutes
- Burke discusses how Deno handles local dependencies by keeping with browser conventions and requiring dependencies using a URL. The Deno info command is briefly discussed and how Deno caches dependencies is also covered in this segment.
- Burke explains Deno's list of approved remote dependencies and live codes importing a remote dependency by URL. How to import a remote dependency without URLs throughout the project is also covered in this segment.
- Burke discusses Deno's compatibility with npm packages and built-node modules. Questions regarding specifying package versions and the meaning of "thinking like a browser" are also covered in this segment.
- Burke demonstrates how to allow and restrict access with the Deno.permissions API and how to specify what permissions Deno has access to. Deno is secure by default and must be allowed permissions to read the file system and make HTTP calls.
- Burke explains how to query specific permissions by making an API status request. Student questions regarding if Node were to implement Deno's permissions functionality and requesting elevated permissions with Deno are also covered in this segment.
Server Side Features
Section Duration: 1 hour, 37 minutes
- Burke live codes a simple web server using server module from the Deno standard library that returns HTML. How to allow only localhost is also briefly talked about in this segment.
- Burke demonstrates how to read parameters off of the URL with Deno's built-in URLSearchParams method and parse the query string obtained.
- Burke walks through using a routeParser node module by importing a routeParser dependency from npm. This process can be used to import and use other types of Node modules in Deno.
- Burke demonstrates how to serve static files multiple ways by using Deno.readFile to return the index.html page, using serveFile to serve the index.html file, and by calling serveFile to directly serve a static file.
- Burke introduces the Oak framework and briefly reviews how to create a new project using Express. The Oak framework was built by the creator of Koa which is similar to Express.
- Burke walks through importing Oak and creating a simple Oak server. How to implement middleware in Oak is also demonstrated in this segment.
- Burke discusses the prebuilt Router middleware in Oak that allows handling of different routes, parameters, and queries. How to create and access a deps.ts file, which holds dependencies, is also covered in this segment.
- Burke demonstrates how to define templates using the handlebars template engine from Deno's third party registry. Creating a Handlebars utilities folder to hold layouts is also covered in this segment.
- Burke walks through how to serve static files in Oak by using Oak's send method and how to implement a global error handler. The send method will route to a public folder and serve static files from that folder.
- Burke demonstrates how to deploy the simple Oak server by bundling the application with Deno. Deploying using Deno's compile method is also covered in this segment.
- Burke walks through creating a container using build image for a Docker extension and deploying by pushing the container to Azure. A student's question regarding creating a volume for a Deno cache is also briefly covered in this segment.
Wrapping Up
Section Duration: 1 minute
- Burke wraps up the course by sharing future expectations for Deno and personal social links.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops