json-server 0.12.2 → 0.14.2
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/.babelrc +8 -6
- package/.eslintrc.js +2 -2
- package/CHANGELOG.md +18 -0
- package/README.md +26 -21
- package/{lib/server/public → dist}/favicon.ico +0 -0
- package/{lib/server/public → dist}/index.html +3 -11
- package/dist/main.css +675 -0
- package/dist/main.js +1 -0
- package/lib/cli/bin.js +4 -1
- package/lib/cli/index.js +13 -8
- package/lib/cli/run.js +98 -109
- package/lib/cli/utils/is.js +3 -4
- package/lib/cli/utils/load.js +71 -38
- package/lib/front/index.js +67 -0
- package/lib/server/body-parser.js +8 -3
- package/lib/server/defaults.js +44 -37
- package/lib/server/index.js +3 -5
- package/lib/server/mixins.js +37 -26
- package/lib/server/rewriter.js +7 -9
- package/lib/server/router/delay.js +4 -3
- package/lib/server/router/get-full-url.js +3 -4
- package/lib/server/router/index.js +59 -59
- package/lib/server/router/nested.js +13 -12
- package/lib/server/router/plural.js +134 -110
- package/lib/server/router/singular.js +35 -17
- package/lib/server/router/validate-data.js +4 -4
- package/lib/server/router/write.js +1 -1
- package/lib/server/utils.js +1 -1
- package/package.json +79 -51
- package/webpack.config.js +21 -0
- package/bin/index.js +0 -3
- package/lib/cli/example.json +0 -9
- package/lib/server/public/images/json.png +0 -0
- package/lib/server/public/main.js +0 -39
- package/lib/server/public/style.css +0 -73
|
@@ -1,62 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var _ = require('lodash');
|
|
5
|
-
var pluralize = require('pluralize');
|
|
6
|
-
var write = require('./write');
|
|
7
|
-
var getFullURL = require('./get-full-url');
|
|
8
|
-
var utils = require('../utils');
|
|
9
|
-
var delay = require('./delay');
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
10
4
|
|
|
11
|
-
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
const express = require('express');
|
|
8
|
+
|
|
9
|
+
const _ = require('lodash');
|
|
10
|
+
|
|
11
|
+
const pluralize = require('pluralize');
|
|
12
|
+
|
|
13
|
+
const write = require('./write');
|
|
14
|
+
|
|
15
|
+
const getFullURL = require('./get-full-url');
|
|
16
|
+
|
|
17
|
+
const utils = require('../utils');
|
|
18
|
+
|
|
19
|
+
const delay = require('./delay');
|
|
20
|
+
|
|
21
|
+
module.exports = (db, name, opts) => {
|
|
12
22
|
// Create router
|
|
13
|
-
|
|
14
|
-
router.use(delay);
|
|
23
|
+
const router = express.Router();
|
|
24
|
+
router.use(delay); // Embed function used in GET /name and GET /name/id
|
|
15
25
|
|
|
16
|
-
// Embed function used in GET /name and GET /name/id
|
|
17
26
|
function embed(resource, e) {
|
|
18
|
-
e && [].concat(e).forEach(
|
|
27
|
+
e && [].concat(e).forEach(externalResource => {
|
|
19
28
|
if (db.get(externalResource).value) {
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
const query = {};
|
|
30
|
+
const singularResource = pluralize.singular(name);
|
|
22
31
|
query[`${singularResource}${opts.foreignKeySuffix}`] = resource.id;
|
|
23
32
|
resource[externalResource] = db.get(externalResource).filter(query).value();
|
|
24
33
|
}
|
|
25
34
|
});
|
|
26
|
-
}
|
|
35
|
+
} // Expand function used in GET /name and GET /name/id
|
|
36
|
+
|
|
27
37
|
|
|
28
|
-
// Expand function used in GET /name and GET /name/id
|
|
29
38
|
function expand(resource, e) {
|
|
30
|
-
e && [].concat(e).forEach(
|
|
31
|
-
|
|
39
|
+
e && [].concat(e).forEach(innerResource => {
|
|
40
|
+
const plural = pluralize(innerResource);
|
|
41
|
+
|
|
32
42
|
if (db.get(plural).value()) {
|
|
33
|
-
|
|
43
|
+
const prop = `${innerResource}${opts.foreignKeySuffix}`;
|
|
34
44
|
resource[innerResource] = db.get(plural).getById(resource[prop]).value();
|
|
35
45
|
}
|
|
36
46
|
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// GET /name
|
|
47
|
+
} // GET /name
|
|
40
48
|
// GET /name?q=
|
|
41
49
|
// GET /name?attr=&attr=
|
|
42
50
|
// GET /name?_end=&
|
|
43
51
|
// GET /name?_start=&_end=&
|
|
44
52
|
// GET /name?_embed=&_expand=
|
|
53
|
+
|
|
54
|
+
|
|
45
55
|
function list(req, res, next) {
|
|
46
56
|
// Resource chain
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// Remove q, _start, _end, ... from req.query to avoid filtering using those
|
|
57
|
+
let chain = db.get(name); // Remove q, _start, _end, ... from req.query to avoid filtering using those
|
|
50
58
|
// parameters
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
let q = req.query.q;
|
|
61
|
+
let _start = req.query._start;
|
|
62
|
+
let _end = req.query._end;
|
|
63
|
+
let _page = req.query._page;
|
|
64
|
+
let _sort = req.query._sort;
|
|
65
|
+
let _order = req.query._order;
|
|
66
|
+
let _limit = req.query._limit;
|
|
67
|
+
let _embed = req.query._embed;
|
|
68
|
+
let _expand = req.query._expand;
|
|
60
69
|
delete req.query.q;
|
|
61
70
|
delete req.query._start;
|
|
62
71
|
delete req.query._end;
|
|
@@ -64,15 +73,16 @@ module.exports = function (db, name, opts) {
|
|
|
64
73
|
delete req.query._order;
|
|
65
74
|
delete req.query._limit;
|
|
66
75
|
delete req.query._embed;
|
|
67
|
-
delete req.query._expand;
|
|
68
|
-
|
|
69
|
-
// Automatically delete query parameters that can't be found
|
|
76
|
+
delete req.query._expand; // Automatically delete query parameters that can't be found
|
|
70
77
|
// in the database
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
|
|
79
|
+
Object.keys(req.query).forEach(query => {
|
|
80
|
+
const arr = db.get(name).value();
|
|
81
|
+
|
|
82
|
+
for (let i in arr) {
|
|
74
83
|
if (_.has(arr[i], query) || query === 'callback' || query === '_' || /_lte$/.test(query) || /_gte$/.test(query) || /_ne$/.test(query) || /_like$/.test(query)) return;
|
|
75
84
|
}
|
|
85
|
+
|
|
76
86
|
delete req.query[query];
|
|
77
87
|
});
|
|
78
88
|
|
|
@@ -83,10 +93,10 @@ module.exports = function (db, name, opts) {
|
|
|
83
93
|
}
|
|
84
94
|
|
|
85
95
|
q = q.toLowerCase();
|
|
96
|
+
chain = chain.filter(obj => {
|
|
97
|
+
for (let key in obj) {
|
|
98
|
+
const value = obj[key];
|
|
86
99
|
|
|
87
|
-
chain = chain.filter(function (obj) {
|
|
88
|
-
for (var key in obj) {
|
|
89
|
-
var value = obj[key];
|
|
90
100
|
if (db._.deepQuery(value, q)) {
|
|
91
101
|
return true;
|
|
92
102
|
}
|
|
@@ -94,31 +104,29 @@ module.exports = function (db, name, opts) {
|
|
|
94
104
|
});
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
Object.keys(req.query).forEach(
|
|
107
|
+
Object.keys(req.query).forEach(key => {
|
|
98
108
|
// Don't take into account JSONP query parameters
|
|
99
109
|
// jQuery adds a '_' query parameter too
|
|
100
110
|
if (key !== 'callback' && key !== '_') {
|
|
101
111
|
// Always use an array, in case req.query is an array
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
chain = chain.filter(function (element) {
|
|
112
|
+
const arr = [].concat(req.query[key]);
|
|
113
|
+
chain = chain.filter(element => {
|
|
105
114
|
return arr.map(function (value) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// get item value based on path
|
|
115
|
+
const isDifferent = /_ne$/.test(key);
|
|
116
|
+
const isRange = /_lte$/.test(key) || /_gte$/.test(key);
|
|
117
|
+
const isLike = /_like$/.test(key);
|
|
118
|
+
const path = key.replace(/(_lte|_gte|_ne|_like)$/, ''); // get item value based on path
|
|
111
119
|
// i.e post.title -> 'foo'
|
|
112
|
-
var elementValue = _.get(element, path);
|
|
113
120
|
|
|
114
|
-
// Prevent toString() failing on undefined or null values
|
|
121
|
+
const elementValue = _.get(element, path); // Prevent toString() failing on undefined or null values
|
|
122
|
+
|
|
123
|
+
|
|
115
124
|
if (elementValue === undefined || elementValue === null) {
|
|
116
125
|
return;
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
if (isRange) {
|
|
120
|
-
|
|
121
|
-
|
|
129
|
+
const isLowerThan = /_gte$/.test(key);
|
|
122
130
|
return isLowerThan ? value <= elementValue : value >= elementValue;
|
|
123
131
|
} else if (isDifferent) {
|
|
124
132
|
return value !== elementValue.toString();
|
|
@@ -127,23 +135,20 @@ module.exports = function (db, name, opts) {
|
|
|
127
135
|
} else {
|
|
128
136
|
return value === elementValue.toString();
|
|
129
137
|
}
|
|
130
|
-
}).reduce(
|
|
131
|
-
return a || b;
|
|
132
|
-
});
|
|
138
|
+
}).reduce((a, b) => a || b);
|
|
133
139
|
});
|
|
134
140
|
}
|
|
135
|
-
});
|
|
141
|
+
}); // Sort
|
|
136
142
|
|
|
137
|
-
// Sort
|
|
138
143
|
if (_sort) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
const _sortSet = _sort.split(',');
|
|
145
|
+
|
|
146
|
+
const _orderSet = (_order || '').split(',').map(s => s.toLowerCase());
|
|
147
|
+
|
|
143
148
|
chain = chain.orderBy(_sortSet, _orderSet);
|
|
144
|
-
}
|
|
149
|
+
} // Slice result
|
|
150
|
+
|
|
145
151
|
|
|
146
|
-
// Slice result
|
|
147
152
|
if (_end || _limit || _page) {
|
|
148
153
|
res.setHeader('X-Total-Count', chain.size());
|
|
149
154
|
res.setHeader('Access-Control-Expose-Headers', `X-Total-Count${_page ? ', Link' : ''}`);
|
|
@@ -153,9 +158,9 @@ module.exports = function (db, name, opts) {
|
|
|
153
158
|
_page = parseInt(_page, 10);
|
|
154
159
|
_page = _page >= 1 ? _page : 1;
|
|
155
160
|
_limit = parseInt(_limit, 10) || 10;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
const page = utils.getPage(chain.value(), _page, _limit);
|
|
162
|
+
const links = {};
|
|
163
|
+
const fullURL = getFullURL(req);
|
|
159
164
|
|
|
160
165
|
if (page.first) {
|
|
161
166
|
links.first = fullURL.replace(`page=${page.current}`, `page=${page.first}`);
|
|
@@ -183,82 +188,104 @@ module.exports = function (db, name, opts) {
|
|
|
183
188
|
_start = parseInt(_start, 10) || 0;
|
|
184
189
|
_limit = parseInt(_limit, 10);
|
|
185
190
|
chain = chain.slice(_start, _start + _limit);
|
|
186
|
-
}
|
|
191
|
+
} // embed and expand
|
|
192
|
+
|
|
187
193
|
|
|
188
|
-
// embed and expand
|
|
189
194
|
chain = chain.cloneDeep().forEach(function (element) {
|
|
190
195
|
embed(element, _embed);
|
|
191
196
|
expand(element, _expand);
|
|
192
197
|
});
|
|
193
|
-
|
|
194
198
|
res.locals.data = chain.value();
|
|
195
199
|
next();
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// GET /name/:id
|
|
200
|
+
} // GET /name/:id
|
|
199
201
|
// GET /name/:id?_embed=&_expand
|
|
202
|
+
|
|
203
|
+
|
|
200
204
|
function show(req, res, next) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
const _embed = req.query._embed;
|
|
206
|
+
const _expand = req.query._expand;
|
|
207
|
+
const resource = db.get(name).getById(req.params.id).value();
|
|
204
208
|
|
|
205
209
|
if (resource) {
|
|
206
210
|
// Clone resource to avoid making changes to the underlying object
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
// Embed other resources based on resource id
|
|
211
|
+
const clone = _.cloneDeep(resource); // Embed other resources based on resource id
|
|
210
212
|
// /posts/1?_embed=comments
|
|
211
|
-
embed(clone, _embed);
|
|
212
213
|
|
|
213
|
-
|
|
214
|
+
|
|
215
|
+
embed(clone, _embed); // Expand inner resources based on id
|
|
214
216
|
// /posts/1?_expand=user
|
|
215
|
-
expand(clone, _expand);
|
|
216
217
|
|
|
218
|
+
expand(clone, _expand);
|
|
217
219
|
res.locals.data = clone;
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
next();
|
|
221
|
-
}
|
|
223
|
+
} // POST /name
|
|
224
|
+
|
|
222
225
|
|
|
223
|
-
// POST /name
|
|
224
226
|
function create(req, res, next) {
|
|
225
|
-
|
|
227
|
+
let resource;
|
|
228
|
+
|
|
229
|
+
if (opts._isFake) {
|
|
230
|
+
const id = db.get(name).createId().value();
|
|
231
|
+
resource = _objectSpread({}, req.body, {
|
|
232
|
+
id
|
|
233
|
+
});
|
|
234
|
+
} else {
|
|
235
|
+
resource = db.get(name).insert(req.body).value();
|
|
236
|
+
}
|
|
226
237
|
|
|
227
238
|
res.setHeader('Access-Control-Expose-Headers', 'Location');
|
|
228
239
|
res.location(`${getFullURL(req)}/${resource.id}`);
|
|
229
|
-
|
|
230
240
|
res.status(201);
|
|
231
241
|
res.locals.data = resource;
|
|
232
|
-
|
|
233
242
|
next();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// PUT /name/:id
|
|
243
|
+
} // PUT /name/:id
|
|
237
244
|
// PATCH /name/:id
|
|
245
|
+
|
|
246
|
+
|
|
238
247
|
function update(req, res, next) {
|
|
239
|
-
|
|
240
|
-
|
|
248
|
+
const id = req.params.id;
|
|
249
|
+
let resource;
|
|
241
250
|
|
|
242
|
-
|
|
251
|
+
if (opts._isFake) {
|
|
252
|
+
resource = db.get(name).getById(id).value();
|
|
243
253
|
|
|
244
|
-
|
|
254
|
+
if (req.method === 'PATCH') {
|
|
255
|
+
resource = _objectSpread({}, resource, req.body);
|
|
256
|
+
} else {
|
|
257
|
+
resource = _objectSpread({}, req.body, {
|
|
258
|
+
id: resource.id
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
let chain = db.get(name);
|
|
263
|
+
chain = req.method === 'PATCH' ? chain.updateById(id, req.body) : chain.replaceById(id, req.body);
|
|
264
|
+
resource = chain.value();
|
|
265
|
+
}
|
|
245
266
|
|
|
246
267
|
if (resource) {
|
|
247
268
|
res.locals.data = resource;
|
|
248
269
|
}
|
|
249
270
|
|
|
250
271
|
next();
|
|
251
|
-
}
|
|
272
|
+
} // DELETE /name/:id
|
|
273
|
+
|
|
252
274
|
|
|
253
|
-
// DELETE /name/:id
|
|
254
275
|
function destroy(req, res, next) {
|
|
255
|
-
|
|
276
|
+
let resource;
|
|
256
277
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
db.get(
|
|
261
|
-
|
|
278
|
+
if (opts._isFake) {
|
|
279
|
+
resource = db.get(name).value();
|
|
280
|
+
} else {
|
|
281
|
+
resource = db.get(name).removeById(req.params.id).value(); // Remove dependents documents
|
|
282
|
+
|
|
283
|
+
const removable = db._.getRemovable(db.getState(), opts);
|
|
284
|
+
|
|
285
|
+
removable.forEach(item => {
|
|
286
|
+
db.get(item.name).removeById(item.id).value();
|
|
287
|
+
});
|
|
288
|
+
}
|
|
262
289
|
|
|
263
290
|
if (resource) {
|
|
264
291
|
res.locals.data = {};
|
|
@@ -267,11 +294,8 @@ module.exports = function (db, name, opts) {
|
|
|
267
294
|
next();
|
|
268
295
|
}
|
|
269
296
|
|
|
270
|
-
|
|
271
|
-
|
|
297
|
+
const w = write(db);
|
|
272
298
|
router.route('/').get(list).post(create, w);
|
|
273
|
-
|
|
274
299
|
router.route('/:id').get(show).put(update, w).patch(update, w).delete(destroy, w);
|
|
275
|
-
|
|
276
300
|
return router;
|
|
277
301
|
};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var write = require('./write');
|
|
5
|
-
var getFullURL = require('./get-full-url');
|
|
6
|
-
var delay = require('./delay');
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
const express = require('express');
|
|
8
|
+
|
|
9
|
+
const write = require('./write');
|
|
10
|
+
|
|
11
|
+
const getFullURL = require('./get-full-url');
|
|
12
|
+
|
|
13
|
+
const delay = require('./delay');
|
|
14
|
+
|
|
15
|
+
module.exports = (db, name, opts) => {
|
|
16
|
+
const router = express.Router();
|
|
10
17
|
router.use(delay);
|
|
11
18
|
|
|
12
19
|
function show(req, res, next) {
|
|
@@ -15,30 +22,41 @@ module.exports = function (db, name) {
|
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
function create(req, res, next) {
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
if (opts._isFake) {
|
|
26
|
+
res.locals.data = req.body;
|
|
27
|
+
} else {
|
|
28
|
+
db.set(name, req.body).value();
|
|
29
|
+
res.locals.data = db.get(name).value();
|
|
30
|
+
}
|
|
20
31
|
|
|
21
32
|
res.setHeader('Access-Control-Expose-Headers', 'Location');
|
|
22
33
|
res.location(`${getFullURL(req)}`);
|
|
23
|
-
|
|
24
34
|
res.status(201);
|
|
25
35
|
next();
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
function update(req, res, next) {
|
|
29
|
-
if (
|
|
30
|
-
|
|
39
|
+
if (opts._isFake) {
|
|
40
|
+
if (req.method === 'PUT') {
|
|
41
|
+
res.locals.data = req.body;
|
|
42
|
+
} else {
|
|
43
|
+
const resource = db.get(name).value();
|
|
44
|
+
res.locals.data = _objectSpread({}, resource, req.body);
|
|
45
|
+
}
|
|
31
46
|
} else {
|
|
32
|
-
|
|
47
|
+
if (req.method === 'PUT') {
|
|
48
|
+
db.set(name, req.body).value();
|
|
49
|
+
} else {
|
|
50
|
+
db.get(name).assign(req.body).value();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
res.locals.data = db.get(name).value();
|
|
33
54
|
}
|
|
34
55
|
|
|
35
|
-
res.locals.data = db.get(name).value();
|
|
36
56
|
next();
|
|
37
57
|
}
|
|
38
58
|
|
|
39
|
-
|
|
40
|
-
|
|
59
|
+
const w = write(db);
|
|
41
60
|
router.route('/').get(show).post(create, w).put(update, w).patch(update, w);
|
|
42
|
-
|
|
43
61
|
return router;
|
|
44
62
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const _ = require('lodash');
|
|
4
4
|
|
|
5
5
|
function validateKey(key) {
|
|
6
6
|
if (key.indexOf('/') !== -1) {
|
|
7
|
-
|
|
7
|
+
const msg = [`Oops, found / character in database property '${key}'.`, '', "/ aren't supported, if you want to tweak default routes, see", 'https://github.com/typicode/json-server/#add-custom-routes'].join('\n');
|
|
8
8
|
throw new Error(msg);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
module.exports =
|
|
12
|
+
module.exports = obj => {
|
|
13
13
|
if (_.isPlainObject(obj)) {
|
|
14
14
|
Object.keys(obj).forEach(validateKey);
|
|
15
15
|
} else {
|
package/lib/server/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,74 +1,94 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"description": "Serves JSON files through REST routes.",
|
|
5
5
|
"main": "./lib/server/index.js",
|
|
6
|
-
"bin": "./bin
|
|
6
|
+
"bin": "./lib/cli/bin.js",
|
|
7
7
|
"directories": {
|
|
8
8
|
"test": "test"
|
|
9
9
|
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "npm run build && cross-env NODE_ENV=test jest && npm run lint",
|
|
12
|
+
"start": "run-p start:**",
|
|
13
|
+
"start:babel-node": "babel-node src/cli/bin db.json -r routes.json",
|
|
14
|
+
"start:webpack": "webpack -d --watch",
|
|
15
|
+
"lint": "eslint . --ignore-path .gitignore",
|
|
16
|
+
"fix": "npm run lint -- --fix",
|
|
17
|
+
"build": "babel src -d lib && webpack -p",
|
|
18
|
+
"toc": "markdown-toc -i README.md",
|
|
19
|
+
"prepublishOnly": "npm test && npm run build && pkg-ok"
|
|
20
|
+
},
|
|
10
21
|
"dependencies": {
|
|
11
|
-
"body-parser": "^1.18.
|
|
12
|
-
"chalk": "^2.
|
|
13
|
-
"compression": "^1.7.
|
|
14
|
-
"connect-pause": "^0.1.
|
|
15
|
-
"cors": "^2.8.
|
|
22
|
+
"body-parser": "^1.18.3",
|
|
23
|
+
"chalk": "^2.4.1",
|
|
24
|
+
"compression": "^1.7.3",
|
|
25
|
+
"connect-pause": "^0.1.1",
|
|
26
|
+
"cors": "^2.8.5",
|
|
16
27
|
"errorhandler": "^1.2.0",
|
|
17
|
-
"express": "^4.16.
|
|
28
|
+
"express": "^4.16.4",
|
|
18
29
|
"express-urlrewrite": "^1.2.0",
|
|
19
30
|
"json-parse-helpfulerror": "^1.0.3",
|
|
20
|
-
"lodash": "^4.11
|
|
31
|
+
"lodash": "^4.17.11",
|
|
21
32
|
"lodash-id": "^0.14.0",
|
|
22
|
-
"lowdb": "^0.
|
|
23
|
-
"method-override": "^
|
|
24
|
-
"morgan": "^1.9.
|
|
25
|
-
"nanoid": "^
|
|
33
|
+
"lowdb": "^1.0.0",
|
|
34
|
+
"method-override": "^3.0.0",
|
|
35
|
+
"morgan": "^1.9.1",
|
|
36
|
+
"nanoid": "^2.0.0",
|
|
26
37
|
"object-assign": "^4.0.1",
|
|
27
|
-
"please-upgrade-node": "^3.
|
|
38
|
+
"please-upgrade-node": "^3.1.1",
|
|
28
39
|
"pluralize": "^7.0.0",
|
|
29
|
-
"request": "^2.
|
|
40
|
+
"request": "^2.88.0",
|
|
30
41
|
"server-destroy": "^1.0.1",
|
|
31
|
-
"update-notifier": "^2.
|
|
32
|
-
"yargs": "^
|
|
42
|
+
"update-notifier": "^2.5.0",
|
|
43
|
+
"yargs": "^12.0.2"
|
|
33
44
|
},
|
|
34
45
|
"devDependencies": {
|
|
35
|
-
"babel
|
|
36
|
-
"babel
|
|
37
|
-
"babel
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
46
|
+
"@babel/cli": "^7.2.3",
|
|
47
|
+
"@babel/core": "^7.2.2",
|
|
48
|
+
"@babel/node": "^7.2.2",
|
|
49
|
+
"@babel/plugin-syntax-jsx": "^7.2.0",
|
|
50
|
+
"@babel/plugin-transform-react-jsx": "^7.2.0",
|
|
51
|
+
"@babel/plugin-transform-regenerator": "^7.0.0",
|
|
52
|
+
"@babel/polyfill": "^7.2.5",
|
|
53
|
+
"@babel/preset-env": "^7.2.3",
|
|
54
|
+
"@babel/register": "^7.0.0",
|
|
55
|
+
"babel-core": "^7.0.0-bridge.0",
|
|
56
|
+
"babel-loader": "^8.0.4",
|
|
57
|
+
"babel-preset-preact": "^1.1.0",
|
|
58
|
+
"babel-preset-react": "^6.24.1",
|
|
59
|
+
"clean-webpack-plugin": "^0.1.19",
|
|
60
|
+
"cross-env": "^5.2.0",
|
|
61
|
+
"css-loader": "^1.0.1",
|
|
62
|
+
"eslint": "^5.11.0",
|
|
63
|
+
"eslint-config-prettier": "^3.3.0",
|
|
64
|
+
"eslint-config-standard": "^12.0.0",
|
|
65
|
+
"eslint-config-standard-preact": "^1.1.6",
|
|
66
|
+
"eslint-plugin-import": "^2.14.0",
|
|
67
|
+
"eslint-plugin-node": "^8.0.0",
|
|
68
|
+
"eslint-plugin-prettier": "^3.0.0",
|
|
69
|
+
"eslint-plugin-promise": "^4.0.1",
|
|
70
|
+
"eslint-plugin-react": "^7.10.0",
|
|
71
|
+
"eslint-plugin-standard": "^4.0.0",
|
|
72
|
+
"html-webpack-plugin": "^3.2.0",
|
|
73
|
+
"husky": "^1.2.1",
|
|
74
|
+
"jest": "^23.6.0",
|
|
49
75
|
"markdown-toc": "^1.2.0",
|
|
76
|
+
"milligram": "^1.3.0",
|
|
77
|
+
"mini-css-extract-plugin": "^0.4.5",
|
|
50
78
|
"mkdirp": "^0.5.1",
|
|
51
|
-
"
|
|
52
|
-
"os-tmpdir": "^
|
|
53
|
-
"pkg-ok": "^
|
|
54
|
-
"
|
|
79
|
+
"npm-run-all": "^4.1.5",
|
|
80
|
+
"os-tmpdir": "^2.0.0",
|
|
81
|
+
"pkg-ok": "^2.3.1",
|
|
82
|
+
"preact": "^8.4.2",
|
|
83
|
+
"prettier": "^1.15.3",
|
|
84
|
+
"promise-polyfill": "^8.1.0",
|
|
55
85
|
"rimraf": "^2.6.2",
|
|
56
86
|
"server-ready": "^0.3.1",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"test": "npm run test:cli && npm run test:server && eslint .",
|
|
63
|
-
"test:cli": "npm run build && cross-env NODE_ENV=test mocha test/cli/*.js",
|
|
64
|
-
"test:server": "cross-env NODE_ENV=test mocha test/server/*.js",
|
|
65
|
-
"start": "babel-node src/cli/bin",
|
|
66
|
-
"fix": "eslint . --fix",
|
|
67
|
-
"build": "babel src -d lib --copy-files",
|
|
68
|
-
"toc": "markdown-toc -i README.md",
|
|
69
|
-
"lf": "crlf --set=LF ./bin/index.js",
|
|
70
|
-
"prepublishOnly": "npm run build && npm run lf && pkg-ok",
|
|
71
|
-
"precommit": "npm test"
|
|
87
|
+
"supertest": "^3.3.0",
|
|
88
|
+
"temp-write": "^3.4.0",
|
|
89
|
+
"webpack": "^4.28.2",
|
|
90
|
+
"webpack-cli": "^3.1.2",
|
|
91
|
+
"whatwg-fetch": "^3.0.0"
|
|
72
92
|
},
|
|
73
93
|
"repository": {
|
|
74
94
|
"type": "git",
|
|
@@ -97,6 +117,14 @@
|
|
|
97
117
|
},
|
|
98
118
|
"homepage": "https://github.com/typicode/json-server",
|
|
99
119
|
"engines": {
|
|
100
|
-
"node": ">=
|
|
120
|
+
"node": ">=6"
|
|
121
|
+
},
|
|
122
|
+
"husky": {
|
|
123
|
+
"hooks": {
|
|
124
|
+
"pre-commit": "npm test"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"jest": {
|
|
128
|
+
"testURL": "http://localhost/"
|
|
101
129
|
}
|
|
102
130
|
}
|