equipped 4.4.0 → 4.4.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [4.4.2](https://github.com/kevinand11/equipped/compare/v4.4.1...v4.4.2) (2024-03-01)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * emit toJSONed base entity ([501c0c7](https://github.com/kevinand11/equipped/commit/501c0c76a8459c6bdbb78d510e6a16725b54c0bc))
11
+ * error message on start connections ([37aba2e](https://github.com/kevinand11/equipped/commit/37aba2e74d05e8afbab05f617667fc934f7a2b3c))
12
+
13
+ ### [4.4.1](https://github.com/kevinand11/equipped/compare/v4.4.0...v4.4.1) (2024-02-24)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * error handler routes ([421ca8a](https://github.com/kevinand11/equipped/commit/421ca8a6fa94af55570d1c0d549ae2238de07db2))
19
+
5
20
  ## [4.4.0](https://github.com/kevinand11/equipped/compare/v4.3.2...v4.4.0) (2024-02-23)
6
21
 
7
22
  ### [4.3.2](https://github.com/kevinand11/equipped/compare/v4.3.1...v4.3.2) (2024-02-21)
@@ -82,7 +82,7 @@ class Instance {
82
82
  (0, exit_1.addWaitBeforeExit)(_a.get().cache.close);
83
83
  }
84
84
  catch (error) {
85
- (0, exit_1.exit)(`'Error starting connections: ${error}`);
85
+ (0, exit_1.exit)(`Error starting connections: ${error}`);
86
86
  }
87
87
  }
88
88
  }
@@ -101,13 +101,13 @@ class Listener {
101
101
  await __classPrivateFieldGet(this, _Listener_subscriber, "f").subscribe();
102
102
  }
103
103
  async created(channels, data) {
104
- await __classPrivateFieldGet(this, _Listener_instances, "m", _Listener_emit).call(this, channels, EmitTypes.created, data);
104
+ await __classPrivateFieldGet(this, _Listener_instances, "m", _Listener_emit).call(this, channels, EmitTypes.created, data.toJSON());
105
105
  }
106
106
  async updated(channels, data) {
107
- await __classPrivateFieldGet(this, _Listener_instances, "m", _Listener_emit).call(this, channels, EmitTypes.updated, data);
107
+ await __classPrivateFieldGet(this, _Listener_instances, "m", _Listener_emit).call(this, channels, EmitTypes.updated, data.toJSON());
108
108
  }
109
109
  async deleted(channels, data) {
110
- await __classPrivateFieldGet(this, _Listener_instances, "m", _Listener_emit).call(this, channels, EmitTypes.deleted, data);
110
+ await __classPrivateFieldGet(this, _Listener_instances, "m", _Listener_emit).call(this, channels, EmitTypes.deleted, data.toJSON());
111
111
  }
112
112
  set callers(callers) {
113
113
  __classPrivateFieldSet(this, _Listener_callers, callers, "f");
package/lib/server/app.js CHANGED
@@ -77,18 +77,18 @@ class Server {
77
77
  return __classPrivateFieldGet(this, _Server_listener, "f");
78
78
  }
79
79
  set routes(routes) {
80
- routes.forEach(({ method, path, controllers }) => {
80
+ routes.forEach(({ method, path, global, controllers }) => {
81
81
  controllers = [parseAuthUser_1.parseAuthUser, ...controllers];
82
- if (path)
82
+ if (!global)
83
83
  __classPrivateFieldGet(this, _Server_expressApp, "f")[method]?.((0, routes_1.formatPath)(path), ...controllers);
84
84
  else
85
85
  __classPrivateFieldGet(this, _Server_expressApp, "f").use(...controllers);
86
86
  });
87
87
  }
88
88
  register(router) {
89
- router.routes.forEach(({ method, path, controllers }) => {
89
+ router.routes.forEach(({ method, path, global, controllers }) => {
90
90
  controllers = [parseAuthUser_1.parseAuthUser, ...controllers];
91
- if (path)
91
+ if (!global)
92
92
  __classPrivateFieldGet(this, _Server_expressApp, "f")[method]?.(path, ...controllers);
93
93
  else
94
94
  __classPrivateFieldGet(this, _Server_expressApp, "f").use(...controllers);
@@ -100,8 +100,8 @@ class Server {
100
100
  async start(port) {
101
101
  const postRoutesRouter = new routes_1.Router();
102
102
  postRoutesRouter.get({ path: '__health' })(async () => `${instance_1.Instance.get().settings.appId} service running`);
103
- postRoutesRouter.all({ middlewares: [middlewares_1.notFoundHandler] })();
104
- postRoutesRouter.all({ middlewares: [middlewares_1.errorHandler] })();
103
+ postRoutesRouter.all({ global: true, middlewares: [middlewares_1.notFoundHandler] })();
104
+ postRoutesRouter.all({ global: true, middlewares: [middlewares_1.errorHandler] })();
105
105
  this.register(postRoutesRouter);
106
106
  return await new Promise((resolve, reject) => {
107
107
  try {
@@ -3,20 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.errorHandler = void 0;
4
4
  const instance_1 = require("../../instance");
5
5
  const controllers_1 = require("../controllers");
6
+ const response_1 = require("../controllers/response");
6
7
  const statusCodes_1 = require("../statusCodes");
7
8
  exports.errorHandler = (0, controllers_1.makeErrorMiddleware)(async (_, err) => {
8
9
  const error = err;
9
- if (error.isCustomError) {
10
- return {
11
- status: error.statusCode,
12
- result: error.serializedErrors
13
- };
14
- }
10
+ if (error.isCustomError)
11
+ return new response_1.Response({
12
+ body: error.serializedErrors,
13
+ status: error.statusCode
14
+ });
15
15
  else {
16
16
  await instance_1.Instance.get().logger.error(err);
17
- return {
18
- status: statusCodes_1.StatusCodes.BadRequest,
19
- result: [{ message: 'Something went wrong', data: err.message }]
20
- };
17
+ return new response_1.Response({
18
+ body: [{ message: 'Something went wrong', data: err.message }],
19
+ status: statusCodes_1.StatusCodes.BadRequest
20
+ });
21
21
  }
22
22
  });
@@ -4,6 +4,7 @@ export type Route = {
4
4
  path: string;
5
5
  method: MethodTypes;
6
6
  controllers: Controller[];
7
+ global?: boolean;
7
8
  };
8
9
  export declare const formatPath: (path: string) => string;
9
10
  export declare const groupRoutes: (parent: string, routes: Route[]) => Route[];
@@ -59,6 +59,8 @@ _Router_config = new WeakMap(), _Router_instances = new WeakSet(), _Router_addRo
59
59
  if (handler)
60
60
  controllers.push((0, controllers_1.makeController)(handler));
61
61
  this.routes.push({
62
+ ...__classPrivateFieldGet(this, _Router_config, "f"),
63
+ ...route,
62
64
  method,
63
65
  controllers,
64
66
  path: (0, exports.formatPath)(`${__classPrivateFieldGet(this, _Router_config, "f")?.path ?? ''}/${route.path ?? ''}`),
@@ -104,6 +104,7 @@ export declare const Validation: {
104
104
  isLaterThan: <T_10 extends Validate.Timeable>(compare: Validate.Timeable, error?: string | undefined) => Validate.Rule<T_10>;
105
105
  isEarlierThan: <T_11 extends Validate.Timeable>(compare: Validate.Timeable, error?: string | undefined) => Validate.Rule<T_11>;
106
106
  ClassPropertiesWrapper: typeof Validate.ClassPropertiesWrapper;
107
+ A: typeof Validate.A;
107
108
  Differ: typeof Validate.Differ;
108
109
  capitalize: (text: string) => string;
109
110
  stripHTML: (html: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "equipped",
3
- "version": "4.4.0",
3
+ "version": "4.4.2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "main": "lib/index.js",
@@ -15,22 +15,22 @@
15
15
  "author": "",
16
16
  "license": "ISC",
17
17
  "devDependencies": {
18
- "@commitlint/cli": "^18.6.1",
19
- "@commitlint/config-conventional": "^18.6.2",
20
- "@types/amqplib": "^0.10.4",
18
+ "@commitlint/cli": "^19.0.3",
19
+ "@commitlint/config-conventional": "^19.0.3",
20
+ "@types/amqplib": "^0.10.5",
21
21
  "@types/bcryptjs": "^2.4.6",
22
22
  "@types/bull": "^3.15.9",
23
23
  "@types/cors": "^2.8.17",
24
24
  "@types/express": "^4.17.21",
25
25
  "@types/express-fileupload": "^1.4.4",
26
- "@types/jsonwebtoken": "^9.0.5",
26
+ "@types/jsonwebtoken": "^9.0.6",
27
27
  "@types/morgan": "^1.9.9",
28
- "@types/node": "^20.11.19",
28
+ "@types/node": "^20.11.24",
29
29
  "@types/pug": "^2.0.10",
30
30
  "@types/supertest": "^6.0.2",
31
- "@typescript-eslint/eslint-plugin": "^7.0.1",
32
- "@typescript-eslint/parser": "^7.0.1",
33
- "eslint": "^8.56.0",
31
+ "@typescript-eslint/eslint-plugin": "^7.1.0",
32
+ "@typescript-eslint/parser": "^7.1.0",
33
+ "eslint": "^8.57.0",
34
34
  "eslint-plugin-promise": "^6.1.1",
35
35
  "husky": "^9.0.11",
36
36
  "standard-version": "^9.5.0",
@@ -46,8 +46,8 @@
46
46
  "compression": "^1.7.4",
47
47
  "cookie-parser": "^1.4.6",
48
48
  "cors": "^2.8.5",
49
- "dotenv": "^16.4.4",
50
- "express": "^4.18.2",
49
+ "dotenv": "^16.4.5",
50
+ "express": "^4.18.3",
51
51
  "express-fileupload": "^1.4.3",
52
52
  "express-rate-limit": "^7.1.5",
53
53
  "express-slow-down": "^2.0.1",
@@ -55,7 +55,7 @@
55
55
  "jsonwebtoken": "^9.0.2",
56
56
  "jwks-rsa": "^3.1.0",
57
57
  "kafkajs": "^2.2.4",
58
- "mongoose": "^8.1.3",
58
+ "mongoose": "^8.2.0",
59
59
  "mongoose-lean-defaults": "^2.2.1",
60
60
  "mongoose-lean-getters": "^1.1.0",
61
61
  "mongoose-lean-virtuals": "^0.9.1",
@@ -66,7 +66,7 @@
66
66
  "redis": "^4.6.13",
67
67
  "socket.io": "4.7.4",
68
68
  "supertest": "^6.3.4",
69
- "valleyed": "4.2.7"
69
+ "valleyed": "4.2.9"
70
70
  },
71
71
  "repository": {
72
72
  "url": "git://github.com/kevinand11/equipped.git"