equipped 4.4.0 → 4.4.1

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,13 @@
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.1](https://github.com/kevinand11/equipped/compare/v4.4.0...v4.4.1) (2024-02-24)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * error handler routes ([421ca8a](https://github.com/kevinand11/equipped/commit/421ca8a6fa94af55570d1c0d549ae2238de07db2))
11
+
5
12
  ## [4.4.0](https://github.com/kevinand11/equipped/compare/v4.3.2...v4.4.0) (2024-02-23)
6
13
 
7
14
  ### [4.3.2](https://github.com/kevinand11/equipped/compare/v4.3.1...v4.3.2) (2024-02-21)
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 ?? ''}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "equipped",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "main": "lib/index.js",
@@ -25,12 +25,12 @@
25
25
  "@types/express-fileupload": "^1.4.4",
26
26
  "@types/jsonwebtoken": "^9.0.5",
27
27
  "@types/morgan": "^1.9.9",
28
- "@types/node": "^20.11.19",
28
+ "@types/node": "^20.11.20",
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.0.2",
32
+ "@typescript-eslint/parser": "^7.0.2",
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,7 +46,7 @@
46
46
  "compression": "^1.7.4",
47
47
  "cookie-parser": "^1.4.6",
48
48
  "cors": "^2.8.5",
49
- "dotenv": "^16.4.4",
49
+ "dotenv": "^16.4.5",
50
50
  "express": "^4.18.2",
51
51
  "express-fileupload": "^1.4.3",
52
52
  "express-rate-limit": "^7.1.5",
@@ -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",