Fork and clone this repo. Then install the dependencies by running:
npm installTo set up your database, update the seeds.json file to contain an object with a key pointing to an array of data, like this:
{
"toys": [
{
"id": 1,
"name": "Woody",
"image": "http://www.pngmart.com/files/3/Toy-Story-Woody-PNG-Photos.png",
"likes": 8
},
{
"id": 2,
"name": "Buzz Lightyear",
"image": "http://www.pngmart.com/files/6/Buzz-Lightyear-PNG-Transparent-Picture.png",
"likes": 14
}
]
}Then, run npm run seed to copy the seed data to the db.json file.
Any time you want to reset your database back to your original data, run npm run seed again. Doing this will overwrite all the data in your db.json file, so make sure you don't have any data in that file that you don't mind losing!
To run your server in development mode, run:
npm run devWhile running in development mode, the server will re-load any time you make changes to the db.json file, so you can test our your seed data.
Free services like Heroku make it simple to deploy your Node server. Heroku also works nicely with Rails, which you'll learn later in the program.
First, download the Heroku CLI.
Then, deploy your app.
Since Heroku deployment integrates with your git repo, you can easily deploy changes to your database. To deploy changes, make sure to commit your code:
git add .
git commit -m "Updated database"Then push your main/default branch up to Heroku:
git push heroku main