@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/express",
3
- "version": "1.2.271",
3
+ "version": "1.2.273",
4
4
  "main": "src/index.js",
5
5
  "engines": {
6
6
  "node": ">= 12.0.0",
@@ -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
- ...options.rulesCreate,
36
- priority: schemaNumber(true),
37
- status: schemaEnum([0, 1, 2], true),
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(function (err, req, res, next) {
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) {
@@ -166,7 +166,7 @@ class SocketServer {
166
166
 
167
167
  return server;
168
168
  }
169
- throw Error('No controllers in use');
169
+ throw new Error('No controllers in use');
170
170
  }
171
171
 
172
172
  setAlertCallback(callback) {
@@ -9,6 +9,6 @@ export default function (mTimeout = 5) {
9
9
  return next();
10
10
  }
11
11
  }
12
- throw ErrorException(SIGNATURE_FAILED);
12
+ throw new ErrorException(SIGNATURE_FAILED);
13
13
  };
14
14
  }
@@ -51,7 +51,7 @@ export default function (type, rules) {
51
51
  const errors = v.validate(reqData, rules);
52
52
 
53
53
  if (Array.isArray(errors)) {
54
- throw ErrorException(INVALID, errors);
54
+ throw new ErrorException(INVALID, errors);
55
55
  }
56
56
  return next();
57
57
  };
package/src/validate.js CHANGED
@@ -149,9 +149,7 @@ export const rulesSlug = {
149
149
  export const rulesKey = {
150
150
  key: schemaKey(),
151
151
  };
152
- export const rulesPlatformType = {
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),