Server setup, part 1
Beginning the process of setting up a server to host the API
Server setup (part 1)#
If your application is still running on http://localhost:3000, you can go to the terminal and cancel the execution by pressing
Ctrl+C. We'll no longer need the development server after this lesson.
Creating a server#
To create a server that will host our application, we'll use Heroku since they have a free tier and it's easy to set up. You'll need to install the Heroku Command Line Interface and log in with your Heroku credentials.
cd up one level to the root
myapp directory. Then run
Next, provision a PostgreSQL database with the following command.
heroku addons:create heroku-postgresql:hobby-dev
Next, create a file called
Procfile with the following command.
echo "web: node server/index.js" > Procfile
To ignore the
node_modules folder and our environment variables, create a file called
.gitignore in the root
myapp directory with the following contents.
Now create a
package.json file using
npm. Accept the defaults automatically by using the
npm init -y