@azteam/express 1.2.271 → 1.2.273
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/package.json
CHANGED
package/src/AdminController.js
CHANGED
|
@@ -6,6 +6,8 @@ import {rulesId, schemaBoolean, schemaEnum, schemaNumber} from './validate';
|
|
|
6
6
|
import {adminRoleMiddleware, paginateMiddleware, validateMiddleware} from './middleware';
|
|
7
7
|
import Controller from './Controller';
|
|
8
8
|
|
|
9
|
+
const ALLOW_FIELDS = ['created_id', 'modified_id', 'restored_id', 'deleted_id', 'resource'];
|
|
10
|
+
|
|
9
11
|
class AdminController extends Controller {
|
|
10
12
|
constructor(pathName, repository, options = {}) {
|
|
11
13
|
super(pathName, repository);
|
|
@@ -26,16 +28,13 @@ class AdminController extends Controller {
|
|
|
26
28
|
|
|
27
29
|
this.paginateOptions = options.paginateOptions || {};
|
|
28
30
|
this.guardResponse = options.guardResponse || [];
|
|
29
|
-
this.allowResponse = options.allowResponse
|
|
30
|
-
? [...options.allowResponse, 'created_id', 'modified_id', 'restored_id', 'deleted_id']
|
|
31
|
-
: ['created_id', 'modified_id', 'restored_id', 'deleted_id'];
|
|
31
|
+
this.allowResponse = options.allowResponse ? [...options.allowResponse, ...ALLOW_FIELDS] : ALLOW_FIELDS;
|
|
32
32
|
|
|
33
|
-
this.rulesCreate =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} || {};
|
|
33
|
+
this.rulesCreate = {
|
|
34
|
+
...options.rulesCreate,
|
|
35
|
+
priority: schemaNumber(true),
|
|
36
|
+
status: schemaEnum([0, 1, 2], true),
|
|
37
|
+
};
|
|
39
38
|
|
|
40
39
|
this.rulesModify = {
|
|
41
40
|
isForceModify: schemaBoolean(true),
|
package/src/Server.js
CHANGED
|
@@ -211,9 +211,6 @@ class Server {
|
|
|
211
211
|
const responseAllows = allow;
|
|
212
212
|
if (_.isArray(guard)) {
|
|
213
213
|
responseGuard = [...guard, '__v', '_id', 'deleted_at', 'updated_at', 'created_id', 'modified_id', 'resource'];
|
|
214
|
-
// if (resType === RES_TYPE.ARRAY || resType === RES_TYPE.DOCS) {
|
|
215
|
-
// responseGuard = [...responseGuard, 'metadata_disable', 'metadata_keywords', 'metadata_description', 'metadata_image_url'];
|
|
216
|
-
// }
|
|
217
214
|
}
|
|
218
215
|
if (resType === RES_TYPE.DOCS) {
|
|
219
216
|
guardData.docs = _.map(data.docs, (item) => {
|
|
@@ -327,7 +324,7 @@ class Server {
|
|
|
327
324
|
throw new ErrorException(NOT_FOUND);
|
|
328
325
|
});
|
|
329
326
|
|
|
330
|
-
app.use(
|
|
327
|
+
app.use((err, req, res, next) => {
|
|
331
328
|
const error = errorCatch(err);
|
|
332
329
|
|
|
333
330
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -374,14 +371,14 @@ class Server {
|
|
|
374
371
|
|
|
375
372
|
return server;
|
|
376
373
|
}
|
|
377
|
-
throw Error('No controllers in use API');
|
|
374
|
+
throw new Error('No controllers in use API');
|
|
378
375
|
}
|
|
379
376
|
|
|
380
377
|
startSocket(port) {
|
|
381
378
|
if (!_.isEmpty(this.controllers)) {
|
|
382
379
|
return this;
|
|
383
380
|
}
|
|
384
|
-
throw Error('No controllers in use SOCKET');
|
|
381
|
+
throw new Error('No controllers in use SOCKET');
|
|
385
382
|
}
|
|
386
383
|
|
|
387
384
|
setAlertCallback(callback) {
|
package/src/SocketServer.js
CHANGED
package/src/validate.js
CHANGED
|
@@ -149,9 +149,7 @@ export const rulesSlug = {
|
|
|
149
149
|
export const rulesKey = {
|
|
150
150
|
key: schemaKey(),
|
|
151
151
|
};
|
|
152
|
-
|
|
153
|
-
type: schemaEnum(['web', 'app']),
|
|
154
|
-
};
|
|
152
|
+
|
|
155
153
|
export const rulesMetadata = {
|
|
156
154
|
metadata_disable: schemaBoolean(true),
|
|
157
155
|
metadata_title: schemaString(0, 255, true),
|