https://github.com/g-vans/my-health-backend-api
https://github.com/g-vans/my-health-backend-api
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/g-vans/my-health-backend-api
- Owner: G-vans
- Created: 2022-10-07T04:23:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-07T04:25:13.000Z (over 2 years ago)
- Last Synced: 2025-01-16T10:38:14.751Z (4 months ago)
- Language: JavaScript
- Size: 64.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSON Server Template
## Setup
Fork and clone this repo. Then install the dependencies by running:
```sh
npm install
```## Seeding Data
To set up your database, update the `db/seeds.json` file to contain an object
with a key pointing to an array of data, like this:```json
{
"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 data from the `db/seeds.json` file to the
`db/db.json` file. `json-server` uses the `db.json` file to create your RESTful
API, so make sure your `db.json` file is always up to date!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!## Running the Server Locally
To run your server in development mode, run:
```sh
npm run dev
```While 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.While your server is running, you can make requests to
[http://localhost:3000](http://localhost:3000). Check it out in the browser to
make sure your server works!## Deploying the Server
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](https://devcenter.heroku.com/articles/getting-started-with-nodejs#set-up).
Then, [deploy your app](https://devcenter.heroku.com/articles/getting-started-with-nodejs#deploy-the-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:```sh
git add .
git commit -m "Updated database"
```Then push your main/default branch up to Heroku:
```sh
git push heroku main
```