You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-16
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,28 @@
2
2
3
3
> Instructions how to deploy the full fake REST API [json-server](https://github.com/typicode/json-server) to various free hosting sites. Should only be used in development purpose but can act as a simpler database for smaller applications.
4
4
5
-
*[**Create your database**](#create-your-database)
6
-
*[Deploy to **Heroku**](#deploy-to-heroku)
7
-
*[Deploy to **Glitch**](#deploy-to-glitch)
8
-
*[Deploy to **Azure**](#deploy-to-azure)
5
+
-[**Create your database**](#create-your-database)
6
+
-[Deploy to **Heroku**](#deploy-to-heroku)
7
+
-[Deploy to **Glitch**](#deploy-to-glitch)
8
+
-[Deploy to **Azure**](#deploy-to-azure)
9
9
10
10
## Create your database
11
11
12
-
1. Press the green `Use this template`-button in the right corner
12
+
1. Press the green `Use this template`-button in the right corner of [this repo](https://github.com/jesperorb/json-server-heroku)
13
13
2. Give your new repo a name and press the green `Create repository from template`-button
14
14
3. Clone your newly created repository to your computer
15
15
16
16
4 . Change the contents of `db.json` to **your own content** according to the [`json-server example`](https://github.com/typicode/json-server#example) and then `commit` your changes to git locally.
17
17
18
18
_this example will create `/posts` route , each resource will have `id`, `title` and `content`. `id` will auto increment!_
19
+
19
20
```json
20
21
{
21
-
"posts":[
22
+
"posts":[
22
23
{
23
-
"id": 0,
24
+
"id": 0,
24
25
"title": "First post!",
25
-
"content": "My first content!"
26
+
"content": "My first content!"
26
27
}
27
28
]
28
29
}
@@ -38,13 +39,13 @@ Heroku is a free hosting service for hosting small projects. Easy setup and depl
38
39
39
40
###### Pros
40
41
41
-
* Easy setup
42
-
* Free
42
+
- Easy setup
43
+
- Free
43
44
44
45
###### Cons
45
46
46
-
* App has to sleep a couple of hours every day.
47
-
* "Powers down" after 30 mins of inactivity. Starts back up when you visit the site but it takes a few extra seconds. Can maybe be solved with [**Kaffeine**](http://kaffeine.herokuapp.com/)
47
+
- App has to sleep a couple of hours every day.
48
+
- "Powers down" after 30 mins of inactivity. Starts back up when you visit the site but it takes a few extra seconds. Can maybe be solved with [**Kaffeine**](http://kaffeine.herokuapp.com/)
48
49
49
50
---
50
51
@@ -57,26 +58,31 @@ Heroku is a free hosting service for hosting small projects. Easy setup and depl
57
58
3 . Install the Heroku CLI on your computer: <br/>[https://devcenter.heroku.com/articles/heroku-cli](https://devcenter.heroku.com/articles/heroku-cli)
58
59
59
60
4 . Connect the Heroku CLI to your account by writing the following command in your terminal and follow the instructions on the command line:
61
+
60
62
```bash
61
63
heroku login
62
64
```
63
65
64
66
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`:
67
+
65
68
```bash
66
69
heroku create my-cool-project
67
70
```
68
71
69
-
6 . Push your app to __Heroku__ (you will see a wall of code)
72
+
6 . Push your app to **Heroku** (you will see a wall of code)
73
+
70
74
```bash
71
75
git push heroku master
72
76
```
73
77
74
78
7 . Visit your newly create app by opening it via heroku:
79
+
75
80
```bash
76
81
heroku open
77
82
```
78
83
79
84
8 . For debugging if something went wrong:
85
+
80
86
```bash
81
87
heroku logs --tail
82
88
```
@@ -86,13 +92,15 @@ heroku logs --tail
86
92
#### How it works
87
93
88
94
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`):
95
+
89
96
```json
90
97
"scripts": {
91
98
"start" : "node server.js"
92
99
}
93
100
```
94
101
95
102
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:
103
+
96
104
```js
97
105
constport=process.env.PORT||4000;
98
106
```
@@ -104,9 +112,9 @@ Not tested 100%. Same as with Heroku, will sleep after a while.
104
112
1. Register for [Glitch](https://glitch.com/) or go to [Glitch/edit](https://glitch.com/)
105
113
2. Click **New Project**
106
114
3. Click **Import from GitHub**
107
-
4. Paste `https://github.com/jesperorb/json-server-heroku.git` into the URL-input and click OK.
115
+
4. Paste `https://github.com/ikramdeveloper/json-server-deploy` into the URL-input and click OK.
108
116
5. Wait for it to setup
109
-
6. Press **Share**-button to get your URL to live site. It should be something for example like: `https://fallabe-pie-snake.glitch.me`. And your DB will be at `https://fallabe-pie-snake.glitch.me/posts`
117
+
6. Press **Share**-button to get your URL to live site. It should be something for example like: `https://seemly-truthful-scribe.glitch.me/`. And your DB will be at `https://seemly-truthful-scribe.glitch.me/posts`
0 commit comments