@fjell/express-router 4.4.4 → 4.4.5
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/commit.sh +8 -0
- package/dist/CItemRouter.cjs +10 -15
- package/dist/CItemRouter.cjs.map +1 -1
- package/dist/CItemRouter.d.ts +1 -1
- package/dist/CItemRouter.js +10 -15
- package/dist/CItemRouter.js.map +1 -1
- package/dist/ItemRouter.cjs +61 -61
- package/dist/ItemRouter.cjs.map +1 -1
- package/dist/ItemRouter.d.ts +6 -6
- package/dist/ItemRouter.js +61 -61
- package/dist/ItemRouter.js.map +1 -1
- package/dist/PItemRouter.cjs +10 -15
- package/dist/PItemRouter.cjs.map +1 -1
- package/dist/PItemRouter.d.ts +1 -1
- package/dist/PItemRouter.js +10 -15
- package/dist/PItemRouter.js.map +1 -1
- package/dist/index.cjs +81 -89
- package/dist/index.cjs.map +1 -1
- package/dist/util/general.d.ts +4 -0
- package/package.json +11 -11
- package/pnpm-workspace.yaml.bak +4 -0
- package/release.sh +89 -0
- package/src/CItemRouter.ts +12 -14
- package/src/ItemRouter.ts +64 -53
- package/src/PItemRouter.ts +11 -12
- package/src/util/general.ts +65 -0
package/dist/index.cjs
CHANGED
|
@@ -65,20 +65,22 @@ class ItemRouter {
|
|
|
65
65
|
return `${this.getPkType()}Pk`;
|
|
66
66
|
});
|
|
67
67
|
_define_property$2(this, "postAllAction", async (req, res)=>{
|
|
68
|
-
this.
|
|
68
|
+
const libOptions = this.lib.definition.options;
|
|
69
|
+
const libOperations = this.lib.operations;
|
|
70
|
+
this.logger.debug('Posting All Action', {
|
|
69
71
|
query: req === null || req === void 0 ? void 0 : req.query,
|
|
70
72
|
params: req === null || req === void 0 ? void 0 : req.params,
|
|
71
73
|
locals: res === null || res === void 0 ? void 0 : res.locals
|
|
72
74
|
});
|
|
73
75
|
const allActionKey = req.path.substring(req.path.lastIndexOf('/') + 1);
|
|
74
|
-
if (!
|
|
76
|
+
if (!libOptions.allActions) {
|
|
75
77
|
this.logger.error('Item Actions are not configured');
|
|
76
78
|
res.status(500).json({
|
|
77
79
|
error: 'Item Actions are not configured'
|
|
78
80
|
});
|
|
79
81
|
return;
|
|
80
82
|
}
|
|
81
|
-
const allAction =
|
|
83
|
+
const allAction = libOptions.allActions[allActionKey];
|
|
82
84
|
if (!allAction) {
|
|
83
85
|
this.logger.error('All Action is not configured', {
|
|
84
86
|
allActionKey
|
|
@@ -89,7 +91,7 @@ class ItemRouter {
|
|
|
89
91
|
return;
|
|
90
92
|
}
|
|
91
93
|
try {
|
|
92
|
-
res.json(await
|
|
94
|
+
res.json(await libOperations.allAction(allActionKey, req.body));
|
|
93
95
|
} catch (err) {
|
|
94
96
|
this.logger.error('Error in All Action', {
|
|
95
97
|
message: err === null || err === void 0 ? void 0 : err.message,
|
|
@@ -99,20 +101,22 @@ class ItemRouter {
|
|
|
99
101
|
}
|
|
100
102
|
});
|
|
101
103
|
_define_property$2(this, "getAllFacet", async (req, res)=>{
|
|
102
|
-
this.
|
|
104
|
+
const libOptions = this.lib.definition.options;
|
|
105
|
+
const libOperations = this.lib.operations;
|
|
106
|
+
this.logger.debug('Getting All Facet', {
|
|
103
107
|
query: req === null || req === void 0 ? void 0 : req.query,
|
|
104
108
|
params: req === null || req === void 0 ? void 0 : req.params,
|
|
105
109
|
locals: res === null || res === void 0 ? void 0 : res.locals
|
|
106
110
|
});
|
|
107
111
|
const facetKey = req.path.substring(req.path.lastIndexOf('/') + 1);
|
|
108
|
-
if (!
|
|
112
|
+
if (!libOptions.allFacets) {
|
|
109
113
|
this.logger.error('Item Facets are not configured');
|
|
110
114
|
res.status(500).json({
|
|
111
115
|
error: 'Item Facets are not configured'
|
|
112
116
|
});
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
115
|
-
const facet =
|
|
119
|
+
const facet = libOptions.allFacets[facetKey];
|
|
116
120
|
if (!facet) {
|
|
117
121
|
this.logger.error('Item Facet is not configured', {
|
|
118
122
|
facetKey
|
|
@@ -127,7 +131,7 @@ class ItemRouter {
|
|
|
127
131
|
...req.query,
|
|
128
132
|
...req.params
|
|
129
133
|
};
|
|
130
|
-
res.json(await
|
|
134
|
+
res.json(await libOperations.allFacet(facetKey, combinedQueryParams));
|
|
131
135
|
} catch (err) {
|
|
132
136
|
this.logger.error('Error in All Facet', {
|
|
133
137
|
message: err === null || err === void 0 ? void 0 : err.message,
|
|
@@ -137,21 +141,23 @@ class ItemRouter {
|
|
|
137
141
|
}
|
|
138
142
|
});
|
|
139
143
|
_define_property$2(this, "postItemAction", async (req, res)=>{
|
|
140
|
-
this.
|
|
144
|
+
const libOptions = this.lib.definition.options;
|
|
145
|
+
const libOperations = this.lib.operations;
|
|
146
|
+
this.logger.debug('Getting Item', {
|
|
141
147
|
query: req === null || req === void 0 ? void 0 : req.query,
|
|
142
148
|
params: req === null || req === void 0 ? void 0 : req.params,
|
|
143
149
|
locals: res === null || res === void 0 ? void 0 : res.locals
|
|
144
150
|
});
|
|
145
151
|
const ik = this.getIk(res);
|
|
146
152
|
const actionKey = req.path.substring(req.path.lastIndexOf('/') + 1);
|
|
147
|
-
if (!
|
|
153
|
+
if (!libOptions.actions) {
|
|
148
154
|
this.logger.error('Item Actions are not configured');
|
|
149
155
|
res.status(500).json({
|
|
150
156
|
error: 'Item Actions are not configured'
|
|
151
157
|
});
|
|
152
158
|
return;
|
|
153
159
|
}
|
|
154
|
-
const action =
|
|
160
|
+
const action = libOptions.actions[actionKey];
|
|
155
161
|
if (!action) {
|
|
156
162
|
this.logger.error('Item Action is not configured', {
|
|
157
163
|
actionKey
|
|
@@ -162,7 +168,7 @@ class ItemRouter {
|
|
|
162
168
|
return;
|
|
163
169
|
}
|
|
164
170
|
try {
|
|
165
|
-
res.json(await
|
|
171
|
+
res.json(await libOperations.action(ik, actionKey, req.body));
|
|
166
172
|
} catch (err) {
|
|
167
173
|
this.logger.error('Error in Item Action', {
|
|
168
174
|
message: err === null || err === void 0 ? void 0 : err.message,
|
|
@@ -172,21 +178,23 @@ class ItemRouter {
|
|
|
172
178
|
}
|
|
173
179
|
});
|
|
174
180
|
_define_property$2(this, "getItemFacet", async (req, res)=>{
|
|
175
|
-
this.
|
|
181
|
+
const libOptions = this.lib.definition.options;
|
|
182
|
+
const libOperations = this.lib.operations;
|
|
183
|
+
this.logger.debug('Getting Item', {
|
|
176
184
|
query: req === null || req === void 0 ? void 0 : req.query,
|
|
177
185
|
params: req === null || req === void 0 ? void 0 : req.params,
|
|
178
186
|
locals: res === null || res === void 0 ? void 0 : res.locals
|
|
179
187
|
});
|
|
180
188
|
const ik = this.getIk(res);
|
|
181
189
|
const facetKey = req.path.substring(req.path.lastIndexOf('/') + 1);
|
|
182
|
-
if (!
|
|
190
|
+
if (!libOptions.facets) {
|
|
183
191
|
this.logger.error('Item Facets are not configured');
|
|
184
192
|
res.status(500).json({
|
|
185
193
|
error: 'Item Facets are not configured'
|
|
186
194
|
});
|
|
187
195
|
return;
|
|
188
196
|
}
|
|
189
|
-
const facet =
|
|
197
|
+
const facet = libOptions.facets[facetKey];
|
|
190
198
|
if (!facet) {
|
|
191
199
|
this.logger.error('Item Facet is not configured', {
|
|
192
200
|
facetKey
|
|
@@ -201,7 +209,7 @@ class ItemRouter {
|
|
|
201
209
|
...req.query,
|
|
202
210
|
...req.params
|
|
203
211
|
};
|
|
204
|
-
res.json(await
|
|
212
|
+
res.json(await libOperations.facet(ik, facetKey, combinedQueryParams));
|
|
205
213
|
} catch (err) {
|
|
206
214
|
this.logger.error('Error in Item Facet', {
|
|
207
215
|
message: err === null || err === void 0 ? void 0 : err.message,
|
|
@@ -211,31 +219,28 @@ class ItemRouter {
|
|
|
211
219
|
}
|
|
212
220
|
});
|
|
213
221
|
_define_property$2(this, "configure", (router)=>{
|
|
214
|
-
this.
|
|
222
|
+
const libOptions = this.lib.definition.options;
|
|
223
|
+
this.logger.debug('Configuring Router', {
|
|
215
224
|
pkType: this.getPkType()
|
|
216
225
|
});
|
|
217
226
|
router.get('/', this.findItems);
|
|
218
227
|
router.post('/', this.createItem);
|
|
219
|
-
this.logger.
|
|
220
|
-
allActions:
|
|
228
|
+
this.logger.default('All Actions supplied to Router', {
|
|
229
|
+
allActions: libOptions.allActions
|
|
221
230
|
});
|
|
222
|
-
if (
|
|
223
|
-
Object.keys(
|
|
224
|
-
this.logger.
|
|
225
|
-
actionKey
|
|
226
|
-
});
|
|
231
|
+
if (libOptions.allActions) {
|
|
232
|
+
Object.keys(libOptions.allActions).forEach((actionKey)=>{
|
|
233
|
+
this.logger.debug('Configuring All Action %s', actionKey);
|
|
227
234
|
// TODO: Ok, this is a bit of a hack, but we need to customize the types of the request handlers
|
|
228
235
|
router.post(`/${actionKey}`, this.postAllAction);
|
|
229
236
|
});
|
|
230
237
|
}
|
|
231
|
-
this.logger.
|
|
232
|
-
allFacets:
|
|
238
|
+
this.logger.default('All Facets supplied to Router', {
|
|
239
|
+
allFacets: libOptions.allFacets
|
|
233
240
|
});
|
|
234
|
-
if (
|
|
235
|
-
Object.keys(
|
|
236
|
-
this.logger.
|
|
237
|
-
facetKey
|
|
238
|
-
});
|
|
241
|
+
if (libOptions.allFacets) {
|
|
242
|
+
Object.keys(libOptions.allFacets).forEach((facetKey)=>{
|
|
243
|
+
this.logger.debug('Configuring All Facet %s', facetKey);
|
|
239
244
|
// TODO: Ok, this is a bit of a hack, but we need to customize the types of the request handlers
|
|
240
245
|
router.get(`/${facetKey}`, this.getAllFacet);
|
|
241
246
|
});
|
|
@@ -244,33 +249,27 @@ class ItemRouter {
|
|
|
244
249
|
itemRouter.get('/', this.getItem);
|
|
245
250
|
itemRouter.put('/', this.updateItem);
|
|
246
251
|
itemRouter.delete('/', this.deleteItem);
|
|
247
|
-
this.logger.
|
|
248
|
-
itemActions:
|
|
252
|
+
this.logger.default('Item Actions supplied to Router', {
|
|
253
|
+
itemActions: libOptions.actions
|
|
249
254
|
});
|
|
250
|
-
if (
|
|
251
|
-
Object.keys(
|
|
252
|
-
this.logger.
|
|
253
|
-
actionKey
|
|
254
|
-
});
|
|
255
|
+
if (libOptions.actions) {
|
|
256
|
+
Object.keys(libOptions.actions).forEach((actionKey)=>{
|
|
257
|
+
this.logger.debug('Configuring Item Action %s', actionKey);
|
|
255
258
|
// TODO: Ok, this is a bit of a hack, but we need to customize the types of the request handlers
|
|
256
259
|
itemRouter.post(`/${actionKey}`, this.postItemAction);
|
|
257
260
|
});
|
|
258
261
|
}
|
|
259
|
-
this.logger.
|
|
260
|
-
itemFacets:
|
|
262
|
+
this.logger.default('Item Facets supplied to Router', {
|
|
263
|
+
itemFacets: libOptions.facets
|
|
261
264
|
});
|
|
262
|
-
if (
|
|
263
|
-
Object.keys(
|
|
264
|
-
this.logger.
|
|
265
|
-
facetKey
|
|
266
|
-
});
|
|
265
|
+
if (libOptions.facets) {
|
|
266
|
+
Object.keys(libOptions.facets).forEach((facetKey)=>{
|
|
267
|
+
this.logger.debug('Configuring Item Facet %s', facetKey);
|
|
267
268
|
// TODO: Ok, this is a bit of a hack, but we need to customize the types of the request handlers
|
|
268
269
|
itemRouter.get(`/${facetKey}`, this.getItemFacet);
|
|
269
270
|
});
|
|
270
271
|
}
|
|
271
|
-
this.logger.
|
|
272
|
-
pkParam: this.getPkParam()
|
|
273
|
-
});
|
|
272
|
+
this.logger.debug('Configuring Item Operations under PK Param %s', this.getPkParam());
|
|
274
273
|
router.use(`/:${this.getPkParam()}`, this.validatePrimaryKeyValue, itemRouter);
|
|
275
274
|
if (this.childRouters) {
|
|
276
275
|
this.configureChildRouters(itemRouter, this.childRouters);
|
|
@@ -285,19 +284,17 @@ class ItemRouter {
|
|
|
285
284
|
} else {
|
|
286
285
|
this.logger.error('Invalid Primary Key', {
|
|
287
286
|
pkParamValue,
|
|
288
|
-
path: req === null || req === void 0 ? void 0 : req.
|
|
287
|
+
path: req === null || req === void 0 ? void 0 : req.originalUrl
|
|
289
288
|
});
|
|
290
289
|
res.status(500).json({
|
|
291
290
|
error: 'Invalid Primary Key',
|
|
292
|
-
path: req === null || req === void 0 ? void 0 : req.
|
|
291
|
+
path: req === null || req === void 0 ? void 0 : req.originalUrl
|
|
293
292
|
});
|
|
294
293
|
}
|
|
295
294
|
});
|
|
296
295
|
_define_property$2(this, "configureChildRouters", (router, childRouters)=>{
|
|
297
296
|
for(const path in childRouters){
|
|
298
|
-
this.logger.
|
|
299
|
-
path
|
|
300
|
-
});
|
|
297
|
+
this.logger.debug('Configuring Child Router at Path %s', path);
|
|
301
298
|
router.use(`/${path}`, childRouters[path]);
|
|
302
299
|
}
|
|
303
300
|
return router;
|
|
@@ -311,19 +308,20 @@ class ItemRouter {
|
|
|
311
308
|
});
|
|
312
309
|
// TODO: Probably a better way to do this, but this postCreate hook only needs the item.
|
|
313
310
|
/* istanbul ignore next */ _define_property$2(this, "postCreateItem", async (item)=>{
|
|
314
|
-
this.logger.
|
|
311
|
+
this.logger.debug('Post Create Item', {
|
|
315
312
|
item
|
|
316
313
|
});
|
|
317
314
|
return item;
|
|
318
315
|
});
|
|
319
316
|
_define_property$2(this, "deleteItem", async (req, res)=>{
|
|
320
|
-
this.
|
|
317
|
+
const libOperations = this.lib.operations;
|
|
318
|
+
this.logger.debug('Deleting Item', {
|
|
321
319
|
query: req.query,
|
|
322
320
|
params: req.params,
|
|
323
321
|
locals: res.locals
|
|
324
322
|
});
|
|
325
323
|
const ik = this.getIk(res);
|
|
326
|
-
const removedItem = await
|
|
324
|
+
const removedItem = await libOperations.remove(ik);
|
|
327
325
|
const item = core.validatePK(removedItem, this.getPkType());
|
|
328
326
|
res.json(item);
|
|
329
327
|
});
|
|
@@ -331,7 +329,8 @@ class ItemRouter {
|
|
|
331
329
|
throw new Error('Method not implemented in an abstract router');
|
|
332
330
|
});
|
|
333
331
|
/* eslint-enable */ _define_property$2(this, "getItem", async (req, res)=>{
|
|
334
|
-
this.
|
|
332
|
+
const libOperations = this.lib.operations;
|
|
333
|
+
this.logger.debug('Getting Item', {
|
|
335
334
|
query: req.query,
|
|
336
335
|
params: req.params,
|
|
337
336
|
locals: res.locals
|
|
@@ -339,7 +338,7 @@ class ItemRouter {
|
|
|
339
338
|
const ik = this.getIk(res);
|
|
340
339
|
try {
|
|
341
340
|
// TODO: What error does validate PK throw, when can that fail?
|
|
342
|
-
const item = core.validatePK(await
|
|
341
|
+
const item = core.validatePK(await libOperations.get(ik), this.getPkType());
|
|
343
342
|
res.json(item);
|
|
344
343
|
} catch (err) {
|
|
345
344
|
if (err instanceof lib.NotFoundError) {
|
|
@@ -366,7 +365,8 @@ class ItemRouter {
|
|
|
366
365
|
}
|
|
367
366
|
});
|
|
368
367
|
_define_property$2(this, "updateItem", async (req, res)=>{
|
|
369
|
-
this.
|
|
368
|
+
const libOperations = this.lib.operations;
|
|
369
|
+
this.logger.debug('Updating Item', {
|
|
370
370
|
body: req === null || req === void 0 ? void 0 : req.body,
|
|
371
371
|
query: req === null || req === void 0 ? void 0 : req.query,
|
|
372
372
|
params: req === null || req === void 0 ? void 0 : req.params,
|
|
@@ -374,12 +374,12 @@ class ItemRouter {
|
|
|
374
374
|
});
|
|
375
375
|
const ik = this.getIk(res);
|
|
376
376
|
const itemToUpdate = this.convertDates(req.body);
|
|
377
|
-
const retItem = core.validatePK(await
|
|
377
|
+
const retItem = core.validatePK(await libOperations.update(ik, itemToUpdate), this.getPkType());
|
|
378
378
|
res.json(retItem);
|
|
379
379
|
});
|
|
380
380
|
_define_property$2(this, "convertDates", (item)=>{
|
|
381
381
|
const events = item.events;
|
|
382
|
-
this.logger.
|
|
382
|
+
this.logger.debug('Converting Dates', {
|
|
383
383
|
item
|
|
384
384
|
});
|
|
385
385
|
if (events) {
|
|
@@ -438,7 +438,6 @@ function _define_property$1(obj, key, value) {
|
|
|
438
438
|
}
|
|
439
439
|
return obj;
|
|
440
440
|
}
|
|
441
|
-
const logger$1 = LibLogger.get('CItemRouter');
|
|
442
441
|
class CItemRouter extends ItemRouter {
|
|
443
442
|
hasParent() {
|
|
444
443
|
return !!this.parentRoute;
|
|
@@ -468,24 +467,22 @@ class CItemRouter extends ItemRouter {
|
|
|
468
467
|
}
|
|
469
468
|
constructor(lib, type, parentRoute, options = {}){
|
|
470
469
|
super(lib, type, options), _define_property$1(this, "parentRoute", void 0), _define_property$1(this, "createItem", async (req, res)=>{
|
|
471
|
-
|
|
470
|
+
const libOperations = this.lib.operations;
|
|
471
|
+
this.logger.default('Creating Item', {
|
|
472
472
|
body: req === null || req === void 0 ? void 0 : req.body,
|
|
473
473
|
query: req === null || req === void 0 ? void 0 : req.query,
|
|
474
474
|
params: req === null || req === void 0 ? void 0 : req.params,
|
|
475
475
|
locals: res === null || res === void 0 ? void 0 : res.locals
|
|
476
476
|
});
|
|
477
477
|
const itemToCreate = this.convertDates(req.body);
|
|
478
|
-
let item = core.validatePK(await
|
|
478
|
+
let item = core.validatePK(await libOperations.create(itemToCreate, {
|
|
479
479
|
locations: this.getLocations(res)
|
|
480
480
|
}), this.getPkType());
|
|
481
481
|
item = await this.postCreateItem(item);
|
|
482
|
+
this.logger.default('Created Item %j', item);
|
|
482
483
|
res.json(item);
|
|
483
484
|
}), _define_property$1(this, "findItems", async (req, res)=>{
|
|
484
|
-
|
|
485
|
-
query: req.query,
|
|
486
|
-
params: req.params,
|
|
487
|
-
locals: res.locals
|
|
488
|
-
});
|
|
485
|
+
const libOperations = this.lib.operations;
|
|
489
486
|
const query = req.query;
|
|
490
487
|
const finder = query['finder'];
|
|
491
488
|
const finderParams = query['finderParams'];
|
|
@@ -493,7 +490,7 @@ class CItemRouter extends ItemRouter {
|
|
|
493
490
|
let items = [];
|
|
494
491
|
if (finder) {
|
|
495
492
|
// If finder is defined? Call a finder.
|
|
496
|
-
logger
|
|
493
|
+
this.logger.default('Finding Items with Finder', {
|
|
497
494
|
finder,
|
|
498
495
|
finderParams,
|
|
499
496
|
one
|
|
@@ -504,15 +501,14 @@ class CItemRouter extends ItemRouter {
|
|
|
504
501
|
item
|
|
505
502
|
] : [];
|
|
506
503
|
} else {
|
|
507
|
-
items = await
|
|
504
|
+
items = await libOperations.find(finder, JSON.parse(finderParams), this.getLocations(res));
|
|
508
505
|
}
|
|
509
506
|
} else {
|
|
510
|
-
logger$1.trace('Finding Items with a query', {
|
|
511
|
-
query: req.query
|
|
512
|
-
});
|
|
513
507
|
// TODO: This is once of the more important places to perform some validaation and feedback
|
|
514
508
|
const itemQuery = core.paramsToQuery(req.query);
|
|
515
|
-
|
|
509
|
+
this.logger.default('Finding Items with Query: %j', itemQuery);
|
|
510
|
+
items = await libOperations.all(itemQuery, this.getLocations(res));
|
|
511
|
+
this.logger.default('Found %d Items with Query', items.length);
|
|
516
512
|
}
|
|
517
513
|
res.json(items.map((item)=>core.validatePK(item, this.getPkType())));
|
|
518
514
|
});
|
|
@@ -533,7 +529,6 @@ function _define_property(obj, key, value) {
|
|
|
533
529
|
}
|
|
534
530
|
return obj;
|
|
535
531
|
}
|
|
536
|
-
const logger = LibLogger.get('PItemRouter');
|
|
537
532
|
class PItemRouter extends ItemRouter {
|
|
538
533
|
getIk(res) {
|
|
539
534
|
const pri = this.getPk(res);
|
|
@@ -541,18 +536,21 @@ class PItemRouter extends ItemRouter {
|
|
|
541
536
|
}
|
|
542
537
|
constructor(lib, keyType, options = {}){
|
|
543
538
|
super(lib, keyType, options), _define_property(this, "createItem", async (req, res)=>{
|
|
544
|
-
|
|
539
|
+
const libOperations = this.lib.operations;
|
|
540
|
+
this.logger.default('Creating Item', {
|
|
545
541
|
body: req.body,
|
|
546
542
|
query: req.query,
|
|
547
543
|
params: req.params,
|
|
548
544
|
locals: res.locals
|
|
549
545
|
});
|
|
550
546
|
const itemToCreate = this.convertDates(req.body);
|
|
551
|
-
let item = core.validatePK(await
|
|
547
|
+
let item = core.validatePK(await libOperations.create(itemToCreate), this.getPkType());
|
|
552
548
|
item = await this.postCreateItem(item);
|
|
549
|
+
this.logger.default('Created Item %j', item);
|
|
553
550
|
res.json(item);
|
|
554
551
|
}), _define_property(this, "findItems", async (req, res)=>{
|
|
555
|
-
|
|
552
|
+
const libOperations = this.lib.operations;
|
|
553
|
+
this.logger.default('Finding Items', {
|
|
556
554
|
query: req.query,
|
|
557
555
|
params: req.params,
|
|
558
556
|
locals: res.locals
|
|
@@ -564,26 +562,20 @@ class PItemRouter extends ItemRouter {
|
|
|
564
562
|
const one = query['one'];
|
|
565
563
|
if (finder) {
|
|
566
564
|
// If finder is defined? Call a finder.
|
|
567
|
-
logger.default('Finding Items with
|
|
568
|
-
finder,
|
|
569
|
-
finderParams,
|
|
570
|
-
one
|
|
571
|
-
});
|
|
565
|
+
this.logger.default('Finding Items with Finder %s %j one:%s', finder, finderParams, one);
|
|
572
566
|
if (one === 'true') {
|
|
573
567
|
const item = await this.lib.findOne(finder, JSON.parse(finderParams));
|
|
574
568
|
items = item ? [
|
|
575
569
|
item
|
|
576
570
|
] : [];
|
|
577
571
|
} else {
|
|
578
|
-
items = await
|
|
572
|
+
items = await libOperations.find(finder, JSON.parse(finderParams));
|
|
579
573
|
}
|
|
580
574
|
} else {
|
|
581
|
-
logger.default('Finding Items with a query', {
|
|
582
|
-
query: req.query
|
|
583
|
-
});
|
|
584
575
|
// TODO: This is once of the more important places to perform some validaation and feedback
|
|
585
576
|
const itemQuery = core.paramsToQuery(req.query);
|
|
586
|
-
|
|
577
|
+
this.logger.default('Finding Items with a query %j', itemQuery);
|
|
578
|
+
items = await libOperations.all(itemQuery);
|
|
587
579
|
}
|
|
588
580
|
res.json(items.map((item)=>core.validatePK(item, this.getPkType())));
|
|
589
581
|
});
|