Book Image

Beginning API Development with Node.js

By : Anthony Nandaa
3.5 (2)
Book Image

Beginning API Development with Node.js

3.5 (2)
By: Anthony Nandaa

Overview of this book

Using the same framework to build both server and client-side applications saves you time and money. This book teaches you how you can use JavaScript and Node.js to build highly scalable APIs that work well with lightweight cross-platform client applications. It begins with the basics of Node.js in the context of backend development, and quickly leads you through the creation of an example client that pairs up with a fully authenticated API implementation. By the end of the book, you’ll have the skills and exposure required to get hands-on with your own API development project.
Table of Contents (9 chapters)

Chapter 3. Building the API - Part 2

This chapter is intended to revisit the previous implementation, this time saving our data in a persistent storage (database). It will also cover authentication, and unit testing and hosting as additional good-to-know concepts (but not essential). It is therefore prudent to put more emphasis on working with the DB using knex.js and authenticating your API with JWT.

By the end of this chapter, you will be able to:

  • Implement database connection with Knex.js
  • Describe commonly used Knex.js methods
  • Rewrite our previous implementation of the todo routes with Knex.js
  • Implement API authentication with JWT
  • Describe the importance of having unit tests for your API
  • Implement basic testing of the API with Lab