Member-only story

Build a REST API with Node.js, TypeScript & MongoDB

Tom Nagle
6 min readMay 9, 2021

--

Update: The video for this guide has been updated https://www.youtube.com/watch?v=BWUi6BS9T5Y

Please watch the updated version of the video instead, it’s much better.

In this guide, we are going to build a REST API with Node.js, TypeScript, and MongoDB. This guide is for junior to mid-level developers that want to build APIs like a senior developer.

Finished repository: https://github.com/TomDoesTech/REST-API-Tutorial

Postman collection: https://github.com/TomDoesTech/REST-API-Tutorial/blob/main/postman_collection.json

Note: This guide uses commands like mkdir and touch. For those that are unfamiliar, mkdir will make a new directory and touch will create a new file. These commands will work on a Mac or Linux OS, but will not work on a Windows machine as far as I’m aware.

Note 2: For the best learning outcome, watch the video above and follow along. Use this article for support when you miss a snippet of code.

Technologies and concepts covered:

  • REST APIs
  • JWTs & refresh tokens
  • Node.js
  • TypeScript
  • MongoDB with Mongoose

Why should you learn how to build a REST API in 2021? Isn’t it all about GraphQL now?

  • REST APIs are still a staple of the web development industry
  • Microservices architectures take advantage of REST
  • You need to know how REST APIs work even if you’re a front-end developer

Bootstrap the application

Start in an empty directory and create and initialize a new Node.js application

yarn init 

Initialize the TypeScript project

npx typescript --init

Create a nodemon.json file and add the following code:

--

--

Tom Nagle
Tom Nagle

Written by Tom Nagle

I am a full stack JavaScript developer, living in Melbourne, Australia. My preferred stack is Mongoose, TypeScript, Node.js, React & GraphQL.

Responses (1)

Write a response