@grandlinex/kernel 0.32.10 → 0.32.11

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/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [v0.32.11] - 2024-07-13
5
+ ### Changed
6
+ - Update Deps
7
+ - Error Handling for BaseApiAction
8
+
4
9
  ## [v0.32.10] - 2023-10-06
5
10
  ### Changed
6
11
  - Breaking Change: BaseApiAction now use XActionEvent
@@ -32,34 +32,61 @@ class BaseAction extends core_1.CoreAction {
32
32
  }
33
33
  if (this.mode === ActionMode.DMZ) {
34
34
  auth.stop();
35
- await this.handler({
36
- res,
37
- req,
38
- next,
39
- data: null,
40
- extension,
41
- });
35
+ try {
36
+ await this.handler({
37
+ res,
38
+ req,
39
+ next,
40
+ data: null,
41
+ extension,
42
+ });
43
+ }
44
+ catch (e) {
45
+ this.error(e);
46
+ this.error(e?.message);
47
+ if (!res.headersSent) {
48
+ res.sendStatus(500);
49
+ }
50
+ }
42
51
  return;
43
52
  }
44
53
  const dat = await cc.bearerTokenValidation(req);
45
54
  auth.stop();
46
55
  if (dat && typeof dat !== 'number') {
47
- await this.handler({
48
- res,
49
- req,
50
- next,
51
- data: dat,
52
- extension,
53
- });
56
+ try {
57
+ await this.handler({
58
+ res,
59
+ req,
60
+ next,
61
+ data: dat,
62
+ extension,
63
+ });
64
+ }
65
+ catch (e) {
66
+ this.error(e);
67
+ this.error(e?.message);
68
+ if (!res.headersSent) {
69
+ res.sendStatus(500);
70
+ }
71
+ }
54
72
  }
55
73
  else if (this.mode === ActionMode.DMZ_WITH_USER) {
56
- await this.handler({
57
- res,
58
- req,
59
- next,
60
- data: null,
61
- extension,
62
- });
74
+ try {
75
+ await this.handler({
76
+ res,
77
+ req,
78
+ next,
79
+ data: null,
80
+ extension,
81
+ });
82
+ }
83
+ catch (e) {
84
+ this.error(e);
85
+ this.error(e?.message);
86
+ if (!res.headersSent) {
87
+ res.sendStatus(500);
88
+ }
89
+ }
63
90
  }
64
91
  else if (dat) {
65
92
  res.sendStatus(dat);
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import express, { Express } from 'express';
4
2
  import http from 'http';
5
3
  import { CorePresenter, IDataBase } from '@grandlinex/core';
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.keepRawBody = void 0;
6
+ exports.keepRawBody = keepRawBody;
7
7
  const express_1 = __importDefault(require("express"));
8
8
  const http_1 = __importDefault(require("http"));
9
9
  const body_parser_1 = __importDefault(require("body-parser"));
@@ -20,7 +20,6 @@ function keepRawBody(req, res, buf, encoding) {
20
20
  }
21
21
  }
22
22
  }
23
- exports.keepRawBody = keepRawBody;
24
23
  class BaseEndpoint extends core_1.CorePresenter {
25
24
  constructor(chanel, module, port) {
26
25
  super(`endpoint-${chanel}`, module);
@@ -29,34 +29,61 @@ export default class BaseAction extends CoreAction {
29
29
  }
30
30
  if (this.mode === ActionMode.DMZ) {
31
31
  auth.stop();
32
- await this.handler({
33
- res,
34
- req,
35
- next,
36
- data: null,
37
- extension,
38
- });
32
+ try {
33
+ await this.handler({
34
+ res,
35
+ req,
36
+ next,
37
+ data: null,
38
+ extension,
39
+ });
40
+ }
41
+ catch (e) {
42
+ this.error(e);
43
+ this.error(e?.message);
44
+ if (!res.headersSent) {
45
+ res.sendStatus(500);
46
+ }
47
+ }
39
48
  return;
40
49
  }
41
50
  const dat = await cc.bearerTokenValidation(req);
42
51
  auth.stop();
43
52
  if (dat && typeof dat !== 'number') {
44
- await this.handler({
45
- res,
46
- req,
47
- next,
48
- data: dat,
49
- extension,
50
- });
53
+ try {
54
+ await this.handler({
55
+ res,
56
+ req,
57
+ next,
58
+ data: dat,
59
+ extension,
60
+ });
61
+ }
62
+ catch (e) {
63
+ this.error(e);
64
+ this.error(e?.message);
65
+ if (!res.headersSent) {
66
+ res.sendStatus(500);
67
+ }
68
+ }
51
69
  }
52
70
  else if (this.mode === ActionMode.DMZ_WITH_USER) {
53
- await this.handler({
54
- res,
55
- req,
56
- next,
57
- data: null,
58
- extension,
59
- });
71
+ try {
72
+ await this.handler({
73
+ res,
74
+ req,
75
+ next,
76
+ data: null,
77
+ extension,
78
+ });
79
+ }
80
+ catch (e) {
81
+ this.error(e);
82
+ this.error(e?.message);
83
+ if (!res.headersSent) {
84
+ res.sendStatus(500);
85
+ }
86
+ }
60
87
  }
61
88
  else if (dat) {
62
89
  res.sendStatus(dat);
@@ -1,5 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import express, { Express } from 'express';
4
2
  import http from 'http';
5
3
  import { CorePresenter, IDataBase } from '@grandlinex/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grandlinex/kernel",
3
- "version": "0.32.10",
3
+ "version": "0.32.11",
4
4
  "description": "GrandLineX is an out-of-the-box server framework on top of ExpressJs.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -48,35 +48,35 @@
48
48
  "dependencies": {
49
49
  "@grandlinex/core": "0.32.0",
50
50
  "@grandlinex/swagger-mate": "0.32.1",
51
- "axios": "1.5.1",
51
+ "axios": "1.6.0",
52
52
  "body-parser": "1.20.2",
53
- "express": "4.18.2",
53
+ "express": "4.19.2",
54
54
  "jsonwebtoken": "9.0.2",
55
- "@types/express": "^4.17.18",
56
- "@types/jsonwebtoken": "^9.0.3"
55
+ "@types/express": "4.17.21",
56
+ "@types/jsonwebtoken": "9.0.6"
57
57
  },
58
58
  "devDependencies": {
59
- "@types/jest": "^29.5.5",
60
- "@types/node": "^20.8.2",
61
- "@typescript-eslint/eslint-plugin": "^6.7.4",
62
- "@typescript-eslint/parser": "^6.7.4",
63
- "cross-env": "^7.0.3",
64
- "eslint": "^8.50.0",
65
- "eslint-config-airbnb": "^19.0.4",
66
- "eslint-config-airbnb-typescript": "^17.1.0",
67
- "eslint-config-prettier": "^9.0.0",
68
- "eslint-plugin-import": "^2.28.1",
69
- "eslint-plugin-jest": "^27.4.2",
70
- "eslint-plugin-jsx-a11y": "^6.7.1",
71
- "eslint-plugin-prettier": "^5.0.0",
72
- "jest": "^29.7.0",
73
- "jest-junit": "^16.0.0",
74
- "prettier": "3.0.3",
75
- "ts-jest": "^29.1.1",
76
- "ts-loader": "^9.4.4",
77
- "ts-node": "^10.9.1",
78
- "typedoc": "^0.25.1",
79
- "typescript": "^5.2.2"
59
+ "@types/jest": "29.5.12",
60
+ "@types/node": "20.14.10",
61
+ "@typescript-eslint/eslint-plugin": "7.16.0",
62
+ "@typescript-eslint/parser": "7.16.0",
63
+ "cross-env": "7.0.3",
64
+ "eslint": "8.57.0",
65
+ "eslint-config-airbnb": "19.0.4",
66
+ "eslint-config-airbnb-typescript": "18.0.0",
67
+ "eslint-config-prettier": "9.1.0",
68
+ "eslint-plugin-import": "2.29.1",
69
+ "eslint-plugin-jest": "28.6.0",
70
+ "eslint-plugin-jsx-a11y": "6.9.0",
71
+ "eslint-plugin-prettier": "5.1.3",
72
+ "jest": "29.7.0",
73
+ "jest-junit": "16.0.0",
74
+ "prettier": "3.3.2",
75
+ "ts-jest": "29.1.5",
76
+ "ts-loader": "9.5.1",
77
+ "ts-node": "10.9.2",
78
+ "typedoc": "0.26.4",
79
+ "typescript": "5.5.3"
80
80
  },
81
81
  "repository": {
82
82
  "type": "git",