Frameworks & Tools – Node.js API with TDD Tutorial

In this post, we will go through the frameworks and the tools that we will be using in this tutorial to build a RESTful API from scratch.

Development Frameworks

This section contains a list of frameworks that we will use to develop the RESTful service.

Node

First in this list is Node.js, apparently as this tutorial is about building a Node.js API. Node.js is a javascript runtime built on Chrome’s V8 JavaScript engine which is Google’s open source high-performance JavaScript engine, written in C++ and used in Google Chrome.

Since the V8 runs on the multiple platforms such as Windows, macOS, and Linux, Node.js runtime is also running on those platforms as well.

As an asynchronous event-driven JavaScript runtime, Node is designed to build scalable network applications. Check the Node’s website for more details and documentation.

Express

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. With a myriad of HTTP utility methods and middleware at your disposal, creating a robust API is quick and easy.

Express provides a thin layer of fundamental web application features, without obscuring Node.js features that you know and love. Many popular frameworks are based on Express which can be found in this link.

MongoDB

MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need. 

MongoDB stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time. The document model maps to the objects in your application code, making data easy to work with.

Mongoose

Mongoose is an elegant MongoDB object modeling for node.js.

Mongoose provides a straight-forward, schema-based solution to model your application data. It includes built-in typecasting, validation, query building, business logic hooks and more, out of the box.

Testing Frameworks

This section contains a list of frameworks that we will use to test the RESTful service with Test-Driven Development approach in this tutorial.

Mocha

As per its website, Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting while mapping uncaught exceptions to the correct test cases.

We will be using this framework to run the unit tests and integration tests for the RESTful service that we are going to create in this tutorial. You can check out the website to know more about it and also documentation for its usage.

Chai

Chai is a TDD / BDD assertion library for node and browser which can be used with any javascript testing framework. Chai has several interfaces that we can choose from BDD (Behavior-Driven Development) and TDD (Test-Driven Development) styles. 

BDD style, which is chain-capable, provides expressive language and readable form. TDD style offers the traditional feel of assertion for testing. Refer the Chai’s website for more information about this library.

Sinon

Sinon library is used to create standalone spies, stubs and mocks for JavaScript. As it works with any unit testing framework, we will use with Mocha for the RESTful service codebase testing along with chai assertion library. Check out the link for Sinon related details.

Development Tools

This section contains a list of tools that we will use to develop and test the RESTful service. 

IDE (Integrated Development Environment)

To build an API with any language or framework, we need to have a development environment set up at the local machine, the developer’s desktop/laptop. 

You can use any of the operating systems (Windows/macOS/Linux) available out there as per your choice and convenience. Depends on the OS of your choice, there are many IDEs available in these options, free/paid.

Each developer has his/her own choice of the IDE as well. Whatever your choice may be, for building the REST API described in this book you would need a NodeJS development supported IDE.

Below are the few of the famous IDEs that you can choose from depends on your OS and you are comfortable with.

  1. WebStorm
  2. IntelliJ IDEA
  3. Visual Studio Code
  4. Sublime Text
  5. Atom

Please check out the index page for this Node.js RESTful API development with TDD approach tutorial with all the posts in sequence in one place.

This blog post is an excerpt from the book Building Node.js REST API with TDD approach. Please check out the link for more information.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.