dl-commons 0.1.1 → 0.1.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.
@@ -6,6 +6,7 @@ declare class HandledException extends HttpException {
6
6
  private readonly _statusCode?;
7
7
  constructor(_errors: RESTError[], _statusCode?: HttpStatus);
8
8
  send(response: Response): void;
9
+ private _resolveStatus;
9
10
  getErrors(): RESTError[];
10
11
  }
11
12
  export { HandledException };
@@ -10,8 +10,13 @@ class HandledException extends common_1.HttpException {
10
10
  this._statusCode = _statusCode;
11
11
  }
12
12
  send(response) {
13
- const responseBody = rest_wrapper_class_1.RESTResponseBody.fail(this._errors, this._statusCode || common_1.HttpStatus.BAD_REQUEST);
14
- response.status(this._statusCode).json(responseBody);
13
+ const status = this._resolveStatus();
14
+ const responseBody = rest_wrapper_class_1.RESTResponseBody.fail(this._errors, status);
15
+ response.status(status).json(responseBody);
16
+ }
17
+ _resolveStatus() {
18
+ const candidate = Number(this._statusCode);
19
+ return Number.isInteger(candidate) && candidate >= 100 && candidate <= 999 ? candidate : common_1.HttpStatus.BAD_REQUEST;
15
20
  }
16
21
  getErrors() {
17
22
  return this._errors;
@@ -1 +1 @@
1
- {"version":3,"file":"custom.exception.js","sourceRoot":"","sources":["../../src/exceptions/custom.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAE3D,mFAAyF;AAEzF,MAAM,gBAAiB,SAAQ,sBAAa;IACxC,YAA6B,OAAoB,EAAmB,WAAwB;QACxF,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,WAAW,IAAI,mBAAU,CAAC,WAAW,CAAC,CAAC;QADzC,YAAO,GAAP,OAAO,CAAa;QAAmB,gBAAW,GAAX,WAAW,CAAa;IAE5F,CAAC;IAEM,IAAI,CAAC,QAAkB;QAC1B,MAAM,YAAY,GAAG,qCAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,IAAI,mBAAU,CAAC,WAAW,CAAC,CAAC;QACrG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAEQ,4CAAgB"}
1
+ {"version":3,"file":"custom.exception.js","sourceRoot":"","sources":["../../src/exceptions/custom.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAE3D,mFAAyF;AAEzF,MAAM,gBAAiB,SAAQ,sBAAa;IACxC,YAA6B,OAAoB,EAAmB,WAAwB;QACxF,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,WAAW,IAAI,mBAAU,CAAC,WAAW,CAAC,CAAC;QADzC,YAAO,GAAP,OAAO,CAAa;QAAmB,gBAAW,GAAX,WAAW,CAAa;IAE5F,CAAC;IAEM,IAAI,CAAC,QAAkB;QAU1B,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACrC,MAAM,YAAY,GAAG,qCAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAEO,cAAc;QAClB,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAU,CAAC,WAAW,CAAC;IACpH,CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAEQ,4CAAgB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dl-commons",
3
3
  "type": "commonjs",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "description": "distance learning commons",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",