json-server 0.17.3 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +44 -20
- package/README.md +52 -589
- package/package.json +39 -92
- package/lib/cli/bin.js +0 -6
- package/lib/cli/index.js +0 -81
- package/lib/cli/run.js +0 -235
- package/lib/cli/utils/is.js +0 -19
- package/lib/cli/utils/load.js +0 -82
- package/lib/server/body-parser.js +0 -10
- package/lib/server/defaults.js +0 -80
- package/lib/server/index.js +0 -11
- package/lib/server/mixins.js +0 -85
- package/lib/server/rewriter.js +0 -16
- package/lib/server/router/delay.js +0 -12
- package/lib/server/router/get-full-url.js +0 -11
- package/lib/server/router/index.js +0 -103
- package/lib/server/router/nested.js +0 -29
- package/lib/server/router/plural.js +0 -305
- package/lib/server/router/singular.js +0 -64
- package/lib/server/router/validate-data.js +0 -19
- package/lib/server/router/write.js +0 -8
- package/lib/server/utils.js +0 -32
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -85
- package/public/script.js +0 -76
- package/public/style.css +0 -113
package/public/index.html
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<link
|
|
4
|
-
rel="stylesheet"
|
|
5
|
-
href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
|
|
6
|
-
integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay"
|
|
7
|
-
crossorigin="anonymous"
|
|
8
|
-
/>
|
|
9
|
-
<link rel="stylesheet" href="style.css" />
|
|
10
|
-
<title>JSON Server</title>
|
|
11
|
-
</head>
|
|
12
|
-
|
|
13
|
-
<body>
|
|
14
|
-
<header>
|
|
15
|
-
<div class="container">
|
|
16
|
-
<nav>
|
|
17
|
-
<ul>
|
|
18
|
-
<li class="title">
|
|
19
|
-
JSON Server
|
|
20
|
-
</li>
|
|
21
|
-
<li>
|
|
22
|
-
<a href="https://github.com/users/typicode/sponsorship">
|
|
23
|
-
<i class="fas fa-heart"></i>GitHub Sponsors
|
|
24
|
-
</a>
|
|
25
|
-
</li>
|
|
26
|
-
<li>
|
|
27
|
-
<a href="https://my-json-server.typicode.com">
|
|
28
|
-
<i class="fas fa-burn"></i>My JSON Server
|
|
29
|
-
</a>
|
|
30
|
-
</li>
|
|
31
|
-
<li>
|
|
32
|
-
<a href="https://thanks.typicode.com">
|
|
33
|
-
<i class="far fa-laugh"></i>Supporters
|
|
34
|
-
</a>
|
|
35
|
-
</li>
|
|
36
|
-
</ul>
|
|
37
|
-
</nav>
|
|
38
|
-
</div>
|
|
39
|
-
</header>
|
|
40
|
-
<main>
|
|
41
|
-
<div class="container">
|
|
42
|
-
<h1>Congrats!</h1>
|
|
43
|
-
<p>
|
|
44
|
-
You're successfully running JSON Server
|
|
45
|
-
<br />
|
|
46
|
-
✧*。٩(ˊᗜˋ*)و✧*。
|
|
47
|
-
</p>
|
|
48
|
-
|
|
49
|
-
<div id="resources"></div>
|
|
50
|
-
|
|
51
|
-
<p>
|
|
52
|
-
To access and modify resources, you can use any HTTP method:
|
|
53
|
-
</p>
|
|
54
|
-
<p>
|
|
55
|
-
<code>GET</code>
|
|
56
|
-
<code>POST</code>
|
|
57
|
-
<code>PUT</code>
|
|
58
|
-
<code>PATCH</code>
|
|
59
|
-
<code>DELETE</code>
|
|
60
|
-
<code>OPTIONS</code>
|
|
61
|
-
</p>
|
|
62
|
-
|
|
63
|
-
<div id="custom-routes"></div>
|
|
64
|
-
|
|
65
|
-
<h1>Documentation</h1>
|
|
66
|
-
<p>
|
|
67
|
-
<a href="https://github.com/typicode/json-server">
|
|
68
|
-
README
|
|
69
|
-
</a>
|
|
70
|
-
</p>
|
|
71
|
-
</div>
|
|
72
|
-
</main>
|
|
73
|
-
|
|
74
|
-
<footer>
|
|
75
|
-
<div class="container">
|
|
76
|
-
<p>
|
|
77
|
-
To replace this page, create a
|
|
78
|
-
<code>./public/index.html</code> file.
|
|
79
|
-
</p>
|
|
80
|
-
</div>
|
|
81
|
-
</footer>
|
|
82
|
-
|
|
83
|
-
<script src="script.js"></script>
|
|
84
|
-
</body>
|
|
85
|
-
</html>
|
package/public/script.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
function ResourceItem({ name, length }) {
|
|
2
|
-
return `
|
|
3
|
-
<li>
|
|
4
|
-
<a href="${name}">/${name}</a>
|
|
5
|
-
<sup>${length ? `${length}x` : 'object'}</sup>
|
|
6
|
-
</li>
|
|
7
|
-
`
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function ResourceList({ db }) {
|
|
11
|
-
return `
|
|
12
|
-
<ul>
|
|
13
|
-
${Object.keys(db)
|
|
14
|
-
.map((name) =>
|
|
15
|
-
ResourceItem({
|
|
16
|
-
name,
|
|
17
|
-
length: Array.isArray(db[name]) && db[name].length,
|
|
18
|
-
}),
|
|
19
|
-
)
|
|
20
|
-
.join('')}
|
|
21
|
-
</ul>
|
|
22
|
-
`
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function NoResources() {
|
|
26
|
-
return `<p>No resources found</p>`
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function ResourcesBlock({ db }) {
|
|
30
|
-
return `
|
|
31
|
-
<div>
|
|
32
|
-
<h1>Resources</h1>
|
|
33
|
-
${Object.keys(db).length ? ResourceList({ db }) : NoResources()}
|
|
34
|
-
</div>
|
|
35
|
-
`
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
window
|
|
39
|
-
.fetch('db')
|
|
40
|
-
.then((response) => response.json())
|
|
41
|
-
.then(
|
|
42
|
-
(db) =>
|
|
43
|
-
(document.getElementById('resources').innerHTML = ResourcesBlock({ db })),
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
function CustomRoutesBlock({ customRoutes }) {
|
|
47
|
-
const rules = Object.keys(customRoutes)
|
|
48
|
-
if (rules.length) {
|
|
49
|
-
return `
|
|
50
|
-
<div>
|
|
51
|
-
<h1>Custom Routes</h1>
|
|
52
|
-
<table>
|
|
53
|
-
${rules
|
|
54
|
-
.map(
|
|
55
|
-
(rule) =>
|
|
56
|
-
`<tr>
|
|
57
|
-
<td>${rule}</td>
|
|
58
|
-
<td><code>⇢</code> ${customRoutes[rule]}</td>
|
|
59
|
-
</tr>`,
|
|
60
|
-
)
|
|
61
|
-
.join('')}
|
|
62
|
-
</table>
|
|
63
|
-
</div>
|
|
64
|
-
`
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
window
|
|
69
|
-
.fetch('__rules')
|
|
70
|
-
.then((response) => response.json())
|
|
71
|
-
.then(
|
|
72
|
-
(customRoutes) =>
|
|
73
|
-
(document.getElementById('custom-routes').innerHTML = CustomRoutesBlock({
|
|
74
|
-
customRoutes,
|
|
75
|
-
})),
|
|
76
|
-
)
|
package/public/style.css
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
display: flex;
|
|
3
|
-
min-height: 100vh;
|
|
4
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
|
5
|
-
Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
|
|
6
|
-
flex-direction: column;
|
|
7
|
-
padding: 0;
|
|
8
|
-
margin: 0;
|
|
9
|
-
color: #3b4252;
|
|
10
|
-
letter-spacing: 0;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.container {
|
|
14
|
-
max-width: 960px;
|
|
15
|
-
margin: auto;
|
|
16
|
-
padding: 1rem;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
header {
|
|
20
|
-
border-bottom: 1px solid #eee;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
header a {
|
|
24
|
-
color: inherit;
|
|
25
|
-
text-decoration: none;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
header a:hover {
|
|
29
|
-
text-decoration: underline;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
nav ul {
|
|
33
|
-
display: flex;
|
|
34
|
-
flex-wrap: nowrap;
|
|
35
|
-
justify-content: space-between;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
nav li.title {
|
|
39
|
-
flex-grow: 5;
|
|
40
|
-
text-align: left;
|
|
41
|
-
font-weight: bold;
|
|
42
|
-
font-size: 1.4rem;
|
|
43
|
-
color: #3b4252;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
nav li {
|
|
47
|
-
flex-grow: 1;
|
|
48
|
-
align-self: center;
|
|
49
|
-
text-align: right;
|
|
50
|
-
color: #4c566a;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.fa-heart {
|
|
54
|
-
color: deeppink;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
main {
|
|
58
|
-
flex: 1;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
footer {
|
|
62
|
-
margin-top: 4rem;
|
|
63
|
-
border-top: 1px solid #eee;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
h1 {
|
|
67
|
-
margin-top: 4rem;
|
|
68
|
-
font-weight: normal;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
i {
|
|
72
|
-
margin-right: 0.5rem;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
a {
|
|
76
|
-
color: #5e81ac;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
a:hover {
|
|
80
|
-
color: #81a1c1;
|
|
81
|
-
text-decoration: underline;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
table {
|
|
85
|
-
margin-left: 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
td {
|
|
89
|
-
border: 0;
|
|
90
|
-
padding: 0 1em 0.5em 0;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
td:first-child {
|
|
94
|
-
width: 1%;
|
|
95
|
-
white-space: nowrap;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
ul {
|
|
99
|
-
list-style-position: inside;
|
|
100
|
-
padding-left: 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
li {
|
|
104
|
-
list-style-type: none;
|
|
105
|
-
margin-bottom: 0.2rem;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
code {
|
|
109
|
-
padding: 0.2rem;
|
|
110
|
-
margin: 0rem 0.2rem;
|
|
111
|
-
border-radius: 0.2rem;
|
|
112
|
-
background: #e5e9f0;
|
|
113
|
-
}
|