NodeJS API-Part 1 / Starting our server using express

This is the 1º tutorial of a complete series of building a production NodeJS API using Express, MySQL and Sequelize”.

Full source code of this class is available at GitHub Martial Arts API Part 1

Photo by Serghei Trofimov on Unsplash

Before we begin you should install the following things on your computer.

If you get stuck in any of the installation you can google it to keep going with the tutorial.

NOTE: This tutorial will cover all the API being built based in a MySQL database. If you are using MongoDB or another I recommend you to check Academind Building a Restful API with NodeJS.


  1. Open any folder in Visual Code;
  2. Open the terminal and run the following line to start your project.
npm init

You can skip all the question or answer any of them if you want.

3. NodeJS will create a file for you called package.json

This file will contain basic information about your project and also it is there where you will check the libraries/packages you download from the internet.


Now we will add express to our app so we can start our server up and running.

  1. Install express.
  2. You just need to type on your Visual Code terminal the following line:
npm install express
run npm install express on visual code

3. express library will be added to your package.json and a new folder called node_modules and a file package-lock.json will be added to your project.


In our final step we will run our express app, for that you need to:

  1. Create a file name app.js and write the following code in this file.

In the first line you import express to your file. In the second line you just create a variable which will hold your express app and then in the last line you start it on port 8000.

To start your server, type in the terminal

node app.js

2. Now go to any browser and type localhost:8000 and you will see a message, which does not mean anything but it proves your app is running.

More exciting things will come in the next tutorials.

Full source code of this class is available at GitHub Martial Arts API Part 1



Flutter and Delphi Developer at Green. Teacher at SoonClass

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store