Better Programming

Advice for programmers.

Follow publication

Member-only story

Creating a REST API in Node.js with Express, TypeScript, MongoDB and Docker — Part 2

Estefanía García Gallardo
Better Programming
Published in
7 min readJul 4, 2019

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:

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:

PokeAPI part 2 directory tree

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:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Estefanía García Gallardo
Estefanía García Gallardo

Written by Estefanía García Gallardo

Just a person who’s in love with computer sciences 💕💕 Developer of Npkill ~ https://npkill.js.org/

No responses yet

Write a response

More from Estefanía García Gallardo and Better Programming