Member-only story
Creating a REST API in Node.js with Express, TypeScript, MongoDB and Docker — Part 2
Creating a MongoDB container and a Mongoose Model

This is part two of a series of articles which will show you how to create a REST API in Node.js, using Express, TypeScript, Docker and MongoDB. Here are the remaining parts of this series:
- Creating a REST API in NodeJS with Express, TypeScript, MongoDB and Docker — Part 1
- Creating a REST API in NodeJS with Express, TypeScript, MongoDB and Docker — Part 3
You can find the full code here.
Introduction
In the previous post, we set up our server and implemented our first GET route, which returned a lovely welcome message. As our goal is to perform basic CRUD operations on our Pokemon data, we need to have a database to store our information.
In this post, we are going to create and deploy a Docker container for our MongoDB database. We are also going to define our Pokemon data model using Mongoose.
Let’s Code
Preview
Once again, before we start, a little preview of how our directory tree will look by the end of this post:

Just as a reminder: to run our project we’re currently using the following command:
npm run start
This said, let us begin.
Creating Our Docker-Compose File
The first thing we are going to do is create a docker-compose.yml
file, on the same level as our src
directory, which is to say, outside of the src
directory.
Once this is done, copy and paste the following code into the newly created file: