0%

Book Description

Build real-world robust web applications and APIs using the modern and expressive Koa Node.js framework.

Key Features

  • Get up and running with Koa.js and leverage its power with node.js
  • Get the most out of Koa Async functions and generators
  • Create real time dynamic serverside apps efficiently with Koa.js

Book Description

Every developer wants to build modular and scalable web applications. Modern versions of JavaScript have made this possible in Node.js, and Koa is a Node.js framework that makes it easy. This book is the ideal introduction for JavaScript developers who want to create scalable server side applications using Node.js and Koa.js.

The book shows you how Koa can be used to start projects from scratch, register custom and existing middleware, read requests, and send responses to users. We will explore the core concepts in Koa, such as error handling, logging, and request and response handling. We will dive into new concepts in JavaScript development, and see how paradigms such as async/await help with modern Node.js application development.

By the end of this book, you will be building robust web applications in Koa using modern development paradigms and techniques of Node.js development.

What you will learn

  • Create a simple server in Node.js and Koa
  • Work with custom middleware in Koa
  • Handle errors in Koa
  • Create routes, handle requests, and send responses from APIs
  • Build views and use templates in Koa
  • Authenticate your application and structure it properly in Koa

Who this book is for

This book is for serverside developers and JavaScript developers who want to use Koa.js and Node.js to create fast and real time back end applications.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Server Side Development with Node.js and Koa.js Quick Start Guide
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Code in action
      4. Conventions used
    4. Get in touch
      1. Reviews
  6. Introducing Koa
    1. Technical requirements
    2. What is Koa?
    3. What can you do with Koa?
    4. Why choose Koa?
    5. When you should not use Koa
    6. Koa versus Express
    7. How can this book help you understand Koa better?
    8. Summary
  7. Getting Started with Koa
    1. Technical requirements
    2. Modern JavaScript
    3. A primer on Node
    4. What is async… await?
      1. The promise class
      2. Introducing async
      3. Introducing await
    5. Installing Koa
    6. Using Babel
    7. Starting a server in Koa
    8. Summary
  8. Koa Core Concepts
    1. Technical requirements
    2. The application object
      1. Useful application methods
      2. Settings
    3. The context object
      1. Context object API
        1. Aliases
      2. The request object
        1. Content negotiation
      3. The response object
    4. Middleware
      1. Cascading in Koa
      2. Defining middleware
      3. Registering middleware
      4. Common middleware
    5. Summary
  9. Handling Errors in Koa
    1. Technical requirements
    2. Catching errors in Koa
      1. Koa's default error handler
      2. Emitting errors
      3. Error event listener
    3. Throwing HTTP errors
    4. Writing error handlers
    5. Summary
  10. Building an API in Koa
    1. Technical requirements
    2. Project setup
      1. Initialization
      2. Installing dependencies
      3. Structure
    3. Building the application
      1. Starting the server
        1. Using Nodemon
      2. Connecting to a database
      3. Creating data models
      4. Setting up the router
      5. Setting up a logger
      6. Creating contact endpoints and controller actions
        1. Retrieving all contacts
        2. Storing new contacts
        3. Retrieving a single contact
        4. Updating a contact
        5. Deleting a contact
      7. Validating requests
    4. Useful notes
    5. Summary
  11. Building an Application in Koa
    1. Technical requirements
    2. About the application
    3. Setting up a project
      1. Installing dependencies
      2. Project structure
    4. Building the application
      1. Starting the server
      2. Connecting to the database
      3. Creating data models
        1. The user model
        2. The post model
      4. Setting up the router
      5. Setting up the views
        1. Using partials
      6. Setting up sessions
      7. Handling authentication
        1. User registration and login
        2. Authentication middleware
        3. Creating controller functions
    5. Summary
  12. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
3.145.60.29