https://github.com/minikin/next-json-server
Mock Json Server
https://github.com/minikin/next-json-server
json server
Last synced: about 1 month ago
JSON representation
Mock Json Server
- Host: GitHub
- URL: https://github.com/minikin/next-json-server
- Owner: minikin
- Created: 2020-01-06T09:48:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-11T08:23:45.000Z (about 5 years ago)
- Last Synced: 2025-10-10T14:27:31.932Z (9 months ago)
- Topics: json, server
- Language: JavaScript
- Homepage:
- Size: 35 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Json Server
## Deploy to Heroku
1. [Create your database](https://github.com/minikin/next-json-server/blob/master/db.json)
2. Create an account on [https://heroku.com](https://heroku.com)
3. Install the Heroku CLI on your computer: [https://devcenter.heroku.com/articles/heroku-cli](https://devcenter.heroku.com/articles/heroku-cli)
4. Connect the Heroku CLI to your account by writing the following command in your terminal and follow the instructions on the command line:
```bash
heroku login
```
5. Then create a remote heroku project, kinda like creating a git repository on GitHub. This will create a project on Heroku with a random name. If you want to name your app you have to supply your own name like `heroku create project-name`:
```bash
heroku create my-cool-project
```
6. Push your app to **Heroku** (you will see a wall of code)
```bash
git push heroku master
```
7. Visit your newly create app by opening it via heroku:
```bash
heroku open
```
8. For debugging if something went wrong:
```bash
heroku logs --tail
```
9. Restart app
```bash
heroku restart -a next-json-server
```
10. Add heroku remote
```sh
heroku git:remote -a thawing-inlet-61413
```
---
## How it works
Heroku will look for a startup-script, this is by default `npm start` so make sure you have that in your `package.json` (assuming your script is called `server.js`):
```json
"scripts": {
"start" : "node server.js"
}
```
You also have to make changes to the port, you can't hardcode a dev-port. But you can reference herokus port. So the code will have the following:
```js
const port = process.env.PORT || 4000;
```