Skip to content

Commit 69321be

Browse files
committed
Display custom routes
1 parent ad9cbdd commit 69321be

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"test": "npm run test:cli && npm run test:server && standard --fix",
5050
"test:cli": "npm run build && cross-env NODE_ENV=test mocha test/cli/*.js",
5151
"test:server": "cross-env NODE_ENV=test mocha test/server/*.js",
52-
"start": "node bin",
52+
"start": "babel-node src/cli/bin",
5353
"prepush": "npm t",
5454
"build": "babel src -d lib --copy-files",
5555
"toc": "markdown-toc -i README.md",

src/server/public/index.html

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ <h4>Routes</h4>
2727
Here are the resources that JSON Server has loaded:
2828
</p>
2929
<ul id="resources">loading, please wait...</ul>
30-
30+
31+
<div id="custom-routes"></div>
32+
3133
<p>
3234
You can view database current state at any time:
3335
</p>
@@ -36,10 +38,10 @@ <h4>Routes</h4>
3638
<a href="db">db</a>
3739
</li>
3840
</ul>
39-
41+
4042
<p>
4143
You can use any HTTP verbs (GET, POST, PUT, PATCH and DELETE) and access your resources from anywhere
42-
using CORS and JSONP.
44+
using CORS or JSONP.
4345
</p>
4446

4547
<h4>Documentation</h4>
@@ -61,17 +63,30 @@ <h4>Issues</h4>
6163
</p>
6264
</div>
6365

64-
6566
<script
6667
src="https://code.jquery.com/jquery-3.0.0.min.js"
6768
integrity="sha256-JmvOoLtYsmqlsWxa7mDSLMwa6dZ9rrIdtrrVYRnDRH0=" crossorigin="anonymous"></script>
6869
<script>
6970
$(function() {
7071
$.get('db').then(function(data) {
71-
$('#resources').empty();
72+
var el = $('#resources')
73+
74+
el.empty()
75+
76+
$.each(data, function(key, value) {
77+
el.append('<li><a href="'+ key + '">' + key + '</a></li>')
78+
})
79+
})
80+
81+
$.get('__rules').then(function(data) {
82+
var el = $('#custom-routes')
83+
84+
el.append('<p>And the custom routes:</p>')
85+
.append('<ul id="custom-routes-list">')
86+
87+
var listEl = $('#custom-routes-list')
7288
$.each(data, function(key, value) {
73-
$('#resources')
74-
.append('<li><a href="'+ key + '">' + key + '</a></li>');
89+
listEl.append('<li>' + key + ' → ' + value + '</li>')
7590
})
7691
})
7792
})

0 commit comments

Comments
 (0)