axe-api 1.7.1 → 1.7.3

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.
@@ -522,6 +522,9 @@ const deepMerge = (base, source) => {
522
522
  }
523
523
  return merged;
524
524
  };
525
+ const normalizeSwaggerPath = (path) => {
526
+ return path.replaceAll(/:([^/]+)/g, "{$1}");
527
+ };
525
528
  const generateDocumentation = () => __awaiter(void 0, void 0, void 0, function* () {
526
529
  const docs = Services_1.DocumentationService.getInstance();
527
530
  const api = Services_1.APIService.getInstance();
@@ -582,10 +585,11 @@ const generateDocumentation = () => __awaiter(void 0, void 0, void 0, function*
582
585
  const modelPatterns = {};
583
586
  const paths = {};
584
587
  for (const endpoint of docs.get()) {
585
- if (paths[endpoint.url] === undefined) {
586
- paths[endpoint.url] = {};
588
+ const normalizedPath = normalizeSwaggerPath(endpoint.url);
589
+ if (paths[normalizedPath] === undefined) {
590
+ paths[normalizedPath] = {};
587
591
  }
588
- modelPatterns[endpoint.url] = endpoint.model;
592
+ modelPatterns[normalizedPath] = endpoint.model;
589
593
  const path = {
590
594
  tags: [endpoint.model],
591
595
  summary: toEndpointSummary(endpoint),
@@ -598,20 +602,21 @@ const generateDocumentation = () => __awaiter(void 0, void 0, void 0, function*
598
602
  if (requestBody) {
599
603
  path.requestBody = requestBody;
600
604
  }
601
- paths[endpoint.url][endpoint.method.toLowerCase()] = path;
605
+ paths[normalizedPath][endpoint.method.toLowerCase()] = path;
602
606
  }
603
607
  const modelPatternsKeys = Object.keys(modelPatterns);
604
608
  // Added custom endpoint
605
609
  for (const custom of docs.getCustoms()) {
606
- if (paths[custom.url] === undefined) {
607
- paths[custom.url] = {};
610
+ const normalizedPath = normalizeSwaggerPath(custom.url);
611
+ if (paths[normalizedPath] === undefined) {
612
+ paths[normalizedPath] = {};
608
613
  }
609
- const samePattern = modelPatternsKeys.find((key) => custom.url.startsWith(key));
614
+ const samePattern = modelPatternsKeys.find((key) => normalizedPath.startsWith(key));
610
615
  const tags = [];
611
616
  if (samePattern) {
612
617
  tags.push(modelPatterns[samePattern]);
613
618
  }
614
- paths[custom.url][custom.method.toLowerCase()] = {
619
+ paths[normalizedPath][custom.method.toLowerCase()] = {
615
620
  tags,
616
621
  description: "Custom endpoint",
617
622
  };
@@ -74,7 +74,7 @@ exports.default = (request, response, next) => __awaiter(void 0, void 0, void 0,
74
74
  // Rollback transaction
75
75
  if (match.hasTransaction && trx) {
76
76
  Services_1.LogService.info("\t🛢 DBTransaction:rollback()");
77
- trx.rollback();
77
+ yield trx.rollback();
78
78
  }
79
79
  if (error.type === "ApiError") {
80
80
  const apiError = error;
@@ -94,7 +94,7 @@ exports.default = (request, response, next) => __awaiter(void 0, void 0, void 0,
94
94
  if (context.res.statusCode() >= 400 && context.res.statusCode() < 599) {
95
95
  if (match.hasTransaction && trx) {
96
96
  Services_1.LogService.info("\t🛢 DBTransaction:rollback()");
97
- trx.rollback();
97
+ yield trx.rollback();
98
98
  }
99
99
  Services_1.LogService.debug(`\tResponse ${context.res.statusCode()}`);
100
100
  break;
@@ -102,7 +102,7 @@ exports.default = (request, response, next) => __awaiter(void 0, void 0, void 0,
102
102
  // We should commit the transaction if there is any
103
103
  if (match.hasTransaction && trx) {
104
104
  Services_1.LogService.info("\t🛢 DBTransaction:commit()");
105
- trx.commit();
105
+ yield trx.commit();
106
106
  }
107
107
  Services_1.LogService.debug(`\t🟢 Response ${context.res.statusCode()}`);
108
108
  // We should brake the for-loop
@@ -24,6 +24,9 @@ class RedisAdaptor {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  try {
26
26
  yield this.client.connect();
27
+ this.client.on("error", (err) => {
28
+ Services_1.LogService.error(`Redis Client Error: ${err.message}`);
29
+ });
27
30
  Services_1.LogService.info("Redis connection done!");
28
31
  this.isConnected = true;
29
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axe-api",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "AXE API is a simple tool to create Rest APIs quickly.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -46,92 +46,78 @@
46
46
  "scripts": {
47
47
  "build": "rm -rf build && tsc && rm -rf build/dev-kit",
48
48
  "build:watch": "tsc -w",
49
- "dev-kit": "tsx watch dev-kit.ts",
50
- "dev-kit:install": "node ./scripts/dev-kit-install.js",
51
- "dev-kit:remove": "node ./scripts/dev-kit-remove.js",
52
- "test": "jest --runInBand",
49
+ "test": "vitest run",
53
50
  "test:all": "npm run lint && npm run prettier:check && npm run test && npm run test:sqlite",
54
- "test:dev": "jest --watch",
51
+ "test:dev": "vitest",
55
52
  "lint": "eslint --max-warnings=0 .",
56
53
  "lint:watch": "esw --watch --color",
57
- "test:postgres11": "sh ./scripts/test-postgres11.sh",
58
- "test:postgres12": "sh ./scripts/test-postgres12.sh",
59
- "test:postgres13": "sh ./scripts/test-postgres13.sh",
60
- "test:postgres14": "sh ./scripts/test-postgres14.sh",
61
- "test:postgres15": "sh ./scripts/test-postgres15.sh",
62
- "test:cockroach": "sh ./scripts/test-cockroach.sh",
63
- "test:mysql57": "sh ./scripts/test-mysql57.sh",
64
- "test:mysql8": "sh ./scripts/test-mysql8.sh",
65
- "test:mariadb": "sh ./scripts/test-mariadb.sh",
66
- "test:sqlite": "sh ./scripts/test-sqlite.sh",
67
54
  "prettier:check": "prettier --check .",
68
55
  "prettier:write": "prettier --write .",
69
56
  "prepare": "husky",
70
57
  "benchmark": "k6 run benchmark/run.js"
71
58
  },
72
59
  "engines": {
73
- "node": ">=18.0.0"
60
+ "node": ">=20.0.0"
74
61
  },
75
62
  "dependencies": {
76
- "body-parser": "^2.2.0",
63
+ "body-parser": "^2.2.2",
77
64
  "change-case": "^4.1.2",
78
65
  "colors": "^1.4.0",
79
- "commander": "^14.0.0",
66
+ "commander": "^14.0.3",
80
67
  "connect": "^3.7.0",
81
- "dotenv": "^16.5.0",
68
+ "dotenv": "^16.6.1",
82
69
  "formidable": "^3.5.4",
83
70
  "knex": "^3.1.0",
84
- "knex-paginate": "^3.1.4",
71
+ "knex-paginate": "^3.2.0",
85
72
  "knex-schema-inspector": "^3.1.0",
86
73
  "nanoid": "^3.3.11",
87
- "pino": "^9.7.0",
88
- "pino-pretty": "^13.0.0",
74
+ "pino": "^9.14.0",
75
+ "pino-pretty": "^13.1.3",
89
76
  "pluralize": "^8.0.0",
90
- "rimraf": "^6.0.1",
77
+ "rimraf": "^6.1.3",
91
78
  "shelljs": "^0.10.0",
92
79
  "validatorjs": "^3.22.1"
93
80
  },
94
81
  "devDependencies": {
95
- "@babel/core": "^7.27.4",
96
- "@babel/preset-env": "^7.27.2",
97
- "@babel/preset-typescript": "^7.27.1",
98
- "@elastic/elasticsearch": "^8.18.2",
82
+ "@babel/core": "^7.29.0",
83
+ "@babel/preset-env": "^7.29.0",
84
+ "@babel/preset-typescript": "^7.28.5",
85
+ "@elastic/elasticsearch": "^8.19.1",
99
86
  "@types/accept-language-parser": "^1.5.8",
100
- "@types/aws-lambda": "^8.10.149",
87
+ "@types/aws-lambda": "^8.10.161",
101
88
  "@types/cors": "^2.8.19",
102
- "@types/formidable": "^3.4.5",
89
+ "@types/formidable": "^3.4.7",
103
90
  "@types/multer": "^1.4.13",
104
91
  "@types/pluralize": "^0.0.33",
105
92
  "@types/validatorjs": "^3.15.5",
106
93
  "@typescript-eslint/eslint-plugin": "^7.18.0",
107
94
  "@typescript-eslint/parser": "^7.18.0",
108
- "babel-jest": "^30.0.0",
109
- "cors": "^2.8.5",
95
+ "cors": "^2.8.6",
110
96
  "eslint": "^8.57.1",
111
97
  "eslint-config-standard": "^17.1.0",
112
- "eslint-plugin-import": "^2.30.0",
98
+ "eslint-plugin-import": "^2.32.0",
113
99
  "eslint-plugin-node": "^11.1.0",
114
100
  "eslint-plugin-promise": "^6.6.0",
115
101
  "eslint-plugin-unicorn": "^56.0.1",
116
102
  "eslint-watch": "^8.0.0",
117
- "glob": "^11.0.3",
103
+ "glob": "^11.1.0",
118
104
  "husky": "^9.1.7",
119
- "jest": "^30.0.0",
120
- "lint-staged": "^16.1.0",
121
- "multer": "^2.0.1",
105
+ "lint-staged": "^16.3.1",
106
+ "multer": "^2.1.0",
122
107
  "mysql": "^2.18.1",
123
- "mysql2": "^3.14.1",
108
+ "mysql2": "^3.18.2",
124
109
  "node-cache": "^5.1.2",
125
- "pg": "^8.16.0",
126
- "prettier": "^3.5.3",
110
+ "pg": "^8.19.0",
111
+ "prettier": "^3.8.1",
127
112
  "redis": "^4.7.1",
128
113
  "robust-validator": "^2.2.1",
129
- "serve-static": "^2.2.0",
114
+ "serve-static": "^2.2.1",
130
115
  "set-value": ">=4.1.0",
131
116
  "sqlite3": "^5.1.7",
132
117
  "ts-node": "^10.9.2",
133
- "tsx": "^4.20.3",
134
- "typescript": "^5.8.3"
118
+ "tsx": "^4.21.0",
119
+ "typescript": "^5.9.3",
120
+ "vitest": "^3.2.4"
135
121
  },
136
122
  "lint-staged": {
137
123
  "**/*": "prettier --write --ignore-unknown"
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Özgür Adem Işıklı <i.ozguradem@gmail.com>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/readme.md DELETED
@@ -1,54 +0,0 @@
1
- <h1 align="center">
2
- <br>
3
- <a href="https://axe-api.com/">
4
- <img src="https://axe-api.com/viking.png" alt="Markdownify" width="200">
5
- </a>
6
- <br>
7
- Axe API
8
- <br>
9
- <a href="https://badge.fury.io/js/axe-api">
10
- <img src="https://badge.fury.io/js/axe-api.svg" alt="npm version" height="18">
11
- </a>
12
- <a href="https://github.com/axe-api/axe-api/actions/workflows/npm-release-publish.yml" target="_blank">
13
- <img src="https://github.com/axe-api/axe-api/actions/workflows/npm-release-publish.yml/badge.svg?branch=master">
14
- </a>
15
- <a href="https://sonarcloud.io/dashboard?id=axe-api_axe-api" target="_blank">
16
- <img src="https://sonarcloud.io/api/project_badges/measure?project=axe-api_axe-api&metric=alert_status">
17
- </a>
18
- <a href="https://github.com/axe-api/axe-api/issues" target="_blank">
19
- <img src="https://img.shields.io/github/issues/axe-api/axe-api.svg">
20
- </a>
21
- <a href="https://opensource.org/licenses/MIT" target="_blank">
22
- <img src="https://img.shields.io/badge/license-MIT-blue.svg">
23
- </a>
24
- </h1>
25
-
26
- **Axe API** is a **TypeScript-based** **Node.js** framework designed to eliminate the need for repetitive tasks associated with common elements while allowing developers to focus on custom logic.
27
-
28
- It offers a comprehensive structure for your API, including numerous features and best practices that will save you time.
29
-
30
- ## 🎥 Video Introduction
31
-
32
- <div style="display: flex; justify-content: center;">
33
-
34
- <a href="https://www.youtube.com/watch?v=3p4jggsNrJA" target="_blank">
35
- <img src="https://raw.githubusercontent.com/axe-api/axe-api/master/youtube.png" />
36
- </a>
37
-
38
- </div>
39
-
40
- ## 📚 Documentation
41
-
42
- Axe API has great documentation. Please [check it out in here](https://axe-api.com/).
43
-
44
- ## 👥 Contributors
45
-
46
- <a href="https://github.com/axe-api/axe-api/graphs/contributors">
47
- <img src="https://contrib.rocks/image?repo=axe-api/axe-api" />
48
- </a>
49
-
50
- Made with [contrib.rocks](https://contrib.rocks).
51
-
52
- ## 📜 License
53
-
54
- [MIT License](LICENSE)