Creating a REST API with RethinkDB, NodeJS, Express

Bruce Lim
Bruce Lim
Mar 24, 2017 · 1 min read

This guide assumes you have some understanding of NodeJS and have it installed on your machine.

Lets get started:

Installing RethinkDB

Starting RethinkDB

rethinkdb --bind all &

visit http://localhost:8080/ to see the admin console

Getting started with Express

You can find an example of this code on github:

This is the directory structure of the finished application, that you will be building.

Lets setup the application structure and directories to work out of.

Install node modules for this app

Here are some configuration files for git and js-beautify, that I like to use in most of my projects.



database settings

.env file

For production update with your own settings and close rethinkdb ports from the public.

Using the configuration file create a DB connection middleware. This will be used throughout the API’s to query the database. Note that it’s set as a property of the request object.

Now that we have all of the dependencies out of the way we can dive into writing the API code. We will be building a Create, Read, Update, and Delete (CRUD) endpoints for users.

Express application configuration to run the API.

Create the routes for this application: this is where the CRUD logic will go. user input validation and business logic will be placed here.


Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade