0%

A curious JavaScript developer's practical guide to deep dive into Deno and get the most out of it for building secure web applications

Key Features

  • Understand Deno's essential concepts and features
  • Learn how to use Deno in real-world scenarios
  • Use Deno to develop, test, and deploy web applications and tools

Book Description

Deno is a JavaScript and TypeScript runtime with secure defaults and a great developer experience. With Deno Web Development, you'll learn all about Deno's primitives, its principles, and how you can use them to build real-world applications. The book is divided into three main sections: an introduction to Deno, building an API from scratch, and testing and deploying a Deno application.

The book starts by getting you up to speed with Deno's runtime and the reason why it was developed. You'll explore some of the concepts introduced by Node, why many of them transitioned into Deno, and why new features were introduced. After understanding Deno and why it was created, you will start to experiment with Deno, exploring the toolchain and writing simple scripts and CLI applications. As you progress to the second section, you will create a simple web application and then add more features to it. This application will evolve from a simple 'hello world' API to a web application connected to the database, with users, authentication, and a JavaScript client. In the third section, the book will take you through topics such as dependency management, configuration and testing, finishing with an application deployed in a cloud environment.

By the end of this web development book, you will become comfortable with using Deno to create, maintain, and deploy secure and reliable web applications.

What you will learn

  • Understand why you should use Deno
  • Get to grips with tooling and the Deno ecosystem
  • Build Deno web applications using existing Node.js knowledge and the newest ECMA Script 6 features
  • Explore the standard library and the benefits of Deno's security model
  • Discover common practices and web frameworks to build a REST API in Deno
  • Structure a web application using common architecture practices
  • Test and deploy a Deno application in the cloud using Docker

Who this book is for

This book is for web developers who want to leverage their JavaScript and TypeScript skills in a secure, simple, and modern runtime, using Deno for web app development. Beginner-level knowledge of Node.js is recommended but not required.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Deno Web Development
  2. Foreword
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Conventions used
    6. Get in touch
    7. Reviews
  7. Section 1: Getting Familiar with Deno
  8. Chapter 1: What is Deno?
    1. A little history
    2. Handling I/O
    3. Node.js enters the scene
    4. Why Deno?
    5. Presenting Deno
    6. A web browser for command-line scripts
    7. Architecture and technologies that support Deno
    8. Inspiration from POSIX systems
    9. Architecture
    10. Grasping Deno's limitations
    11. Not as stable as Node.js
    12. Better HTTP latency but worse throughput
    13. Compatibility with Node.js
    14. TypeScript compiler speed
    15. Lack of plugins/extensions
    16. Exploring use cases
    17. A flexible scripting language
    18. Safer desktop applications
    19. A quick and complete environment to write tools
    20. Running on embedded devices
    21. Generating browser-compatible code
    22. Full-fledged APIs
    23. Summary
  9. Chapter 2: The Toolchain
    1. Technical requirements
    2. Setting up the environment
    3. Installing Deno
    4. Installing VS Code
    5. Shell completions
    6. Hello World
    7. Debugging code in Deno
    8. Modules and third-party dependencies
    9. Locally cached dependencies
    10. Managing dependencies
    11. Import maps
    12. Inspecting modules
    13. Exploring the documentation
    14. Running and installing scripts
    15. Installing utility scripts
    16. Permissions
    17. Using the test command
    18. Filtering tests
    19. Fail fast
    20. Formatting and linting
    21. Formatting
    22. Lint
    23. Bundling code
    24. Compiling to a binary
    25. Using the upgrade command
    26. Summary
  10. Chapter 3: The Runtime and Standard Library
    1. Technical requirements
    2. The Deno runtime
    3. Stability
    4. Program lifecycle
    5. Web APIs
    6. Exploring the Deno namespace
    7. Building a simple ls command
    8. Using dynamic permissions
    9. Using the filesystem APIs
    10. Using buffers
    11. Reading and writing from Deno.Buffer
    12. Using the standard library
    13. Adding colors to our simple ls
    14. Building a web server using the HTTP module
    15. Summary
  11. Section 2: Building an Application
  12. Chapter 4: Building a Web Application
    1. Technical requirements
    2. Structuring a web application
    3. Deno as an unopinionated tool
    4. The most important part of an application
    5. What is our application about?
    6. Understanding folder structure and application architecture
    7. Developing the business logic
    8. Developing the data accessing logic
    9. Creating the web server
    10. Wiring the web server to the business logic
    11. Exploring Deno HTTP frameworks
    12. What alternatives exist?
    13. The verdict
    14. Summary
  13. Chapter 5: Adding Users and Migrating to Oak
    1. Technical requirements
    2. Managing dependencies and lock files
    3. Using a centralized dependency file
    4. Creating a lock file
    5. Writing a web server with Oak
    6. Adding event listeners to an Oak application
    7. Handling routes in an Oak application
    8. Connecting the router to the application
    9. Adding users to the application
    10. Creating the user module
    11. Storing a user in the database
    12. Creating the user repository
    13. Creating the register endpoint
    14. Wiring the user controller with the web layer
    15. Summary
  14. Chapter 6: Adding Authentication and Connecting to the Database
    1. Technical requirements
    2. Using middleware functions
    3. How does middleware work?
    4. Adding request timing via middleware
    5. Adding request logging via middleware
    6. Adding authentication
    7. Creating the login business logic
    8. Creating the login endpoint
    9. Adding authorization with JWT
    10. Returning a token from login
    11. Making an authenticated route
    12. Connecting to MongoDB
    13. Creating a User MongoDB repository
    14. Installing the MongoDB client library
    15. Developing the MongoDB repository
    16. Connecting the application to MongoDB
    17. Connecting to a MongoDB cluster
    18. Summary
  15. Chapter 7: HTTPS, Extracting Configuration, and Deno in the Browser
    1. Technical requirements
    2. Enabling CORS and HTTPS
    3. Enabling CORS
    4. Enabling HTTPS
    5. Extracting configuration and secrets
    6. Creating a configuration file
    7. Accessing secret values
    8. Running Deno code in the browser
    9. Summary
  16. Section 3: Testing and Deploying
  17. Chapter 8: Testing – Unit and Integration
    1. Technical requirements
    2. Writing your first test in Deno
    3. Defining a test
    4. A unit test for MuseumController
    5. Writing an integration test
    6. Testing the web server
    7. Creating integration tests for the application
    8. Testing the application together with the API client
    9. Benchmarking parts of the application
    10. Summary
  18. Chapter 9: Deploying a Deno Application
    1. Technical requirements
    2. Preparing the environment for the application
    3. Creating a Dockerfile for the Deno application
    4. Running a Terminal inside a container
    5. Building and running the application in Heroku
    6. Creating the application in Heroku
    7. Building and running the Docker image
    8. Configuring the application for deployment
    9. Getting the application port from the environment
    10. Summary
  19. Chapter 10: What's Next?
    1. Looking back at our journey
    2. Deno's roadmap
    3. Deno's future and community
    4. Interesting things happening in the community
    5. Publishing a package to Deno's official registry
    6. Summary
    7. Why subscribe?
  20. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Leave a review - let other readers know what you think
52.23.201.145