axe-api 0.30.0-rc9 → 0.30.0

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 ADDED
@@ -0,0 +1,221 @@
1
+ # Release Notes
2
+
3
+ ## [0.30.0 (2023-04-05)](https://github.com/axe-api/axe-api/compare/0.30.0...0.22.0)
4
+
5
+ ### Breaking Changes
6
+
7
+ - Added new Serizaliation folder [#125](https://github.com/axe-api/axe-api/issues/125)
8
+ - New hook/event folder structure [#146](https://github.com/axe-api/axe-api/issues/146)
9
+ - Limiting query features by configurations [#38](https://github.com/axe-api/axe-api/issues/38)
10
+ - Removing external dependencies from axe-core [#151](https://github.com/axe-api/axe-api/issues/151)
11
+
12
+ ## [0.22.0 (2023-01-29)](https://github.com/axe-api/axe-api/compare/0.22.0...0.21.0)
13
+
14
+ ### Features
15
+
16
+ - Added Soft-Deleting feature [#41](https://github.com/axe-api/axe-api/issues/41)
17
+
18
+ ### Fixed
19
+
20
+ - Fixed model relation route URLs [#141](https://github.com/axe-api/axe-api/issues/141)
21
+
22
+ ## [0.21.0 (2022-12-28)](https://github.com/axe-api/axe-api/compare/0.21.0...0.20.4)
23
+
24
+ ### Features
25
+
26
+ - Added `i18n` support. [#44](https://github.com/axe-api/axe-api/issues/44)
27
+
28
+ ## [0.20.4 (2022-12-24)](https://github.com/axe-api/axe-api/compare/0.20.4...0.20.3)
29
+
30
+ ### Fixed
31
+
32
+ - Fixed [#124](https://github.com/axe-api/axe-api/issues/124)
33
+ - Throwing errors in the `development` environment has been fixed.
34
+ - Unbuilt integration test issue has been fixed.
35
+
36
+ ## [0.20.3 (2022-12-24)](https://github.com/axe-api/axe-api/compare/0.20.3...0.20.0)
37
+
38
+ ### Fixed
39
+
40
+ - NPM publish bugs
41
+
42
+ ## [0.20.0 (2022-12-24)](https://github.com/axe-api/axe-api/compare/0.20.0...0.19.2)
43
+
44
+ In the whole application, TypeScript becomes the new language except for migration files and it's structure. You can read the documentation about how to migrate from `0.19.2` to `0.20.0`.
45
+
46
+ ### Breaking Changes
47
+
48
+ #### Naming Changes
49
+
50
+ - File extensions: `User.js` to `User.ts`
51
+ - `LOG_LEVELS` constant variable has been changed with `LogLevels` enum.
52
+ - `HANDLERS` constant variable has been changed with `HandlerTypes` enum.
53
+ - `IoC` service has been renamed as `IoCService`.
54
+ - Hooks and Event files' names should be singular;
55
+ - `UserHooks.js` => `UserHook.ts`
56
+ - `UserEvents.js` => `UserEvent.ts`
57
+
58
+ #### Interface Changes
59
+
60
+ - `validations()` getter should return `IMethodBaseValidations` interface.
61
+ - In hook functions, `IHookParameter` interface should be used as the parameter type.
62
+ - Init functions (`onBeforeInit`, `onAfterInit`) should be use the `Express` type;
63
+ - `const onBeforeInit = async ({ app }) => {` => `const onBeforeInit = async (app: Express) => {`
64
+ - `const onAfterInit = async ({ app }) => {` => `const onAfterInit = async (app: Express) => {`
65
+ - Application config should be implemented `IApplicationConfig` interface.
66
+
67
+ #### Implementation Changes
68
+
69
+ - Starting server part has been changed;
70
+ - `const server = new Server(appFolder)` => `const server = new Server()`
71
+ - `server.listen()` => `server.start(__dirname);`
72
+ - `knexfile.js` should not use the `app/Application/Config.js` anymore.
73
+
74
+ ## [0.19.2 (2022-01-22)](https://github.com/axe-api/axe-api/compare/0.19.2...0.19.1)
75
+
76
+ ### Fixed
77
+
78
+ - Fixed the calling `onBeforePaginate` and `onBeforeShow` hooks bug.
79
+
80
+ ## [0.19.1 (2022-01-22)](https://github.com/axe-api/axe-api/compare/0.19.1...0.19.0)
81
+
82
+ ### Fixed
83
+
84
+ - knex.js version update.
85
+
86
+ ## [0.19.0 (2021-12-05)](https://github.com/axe-api/axe-api/compare/0.19.0...0.18.1)
87
+
88
+ ### Fixed
89
+
90
+ - [#110](https://github.com/axe-api/axe-api/issues/110)
91
+
92
+ ### Enhancements
93
+
94
+ - [#106](https://github.com/axe-api/axe-api/issues/106)
95
+
96
+ ## [0.18.1 (2021-12-02)](https://github.com/axe-api/axe-api/compare/0.18.1...0.18.0)
97
+
98
+ ### Fixed
99
+
100
+ - [#117](https://github.com/axe-api/axe-api/issues/117)
101
+
102
+ ## [0.18.0 (2021-11-30)](https://github.com/axe-api/axe-api/compare/0.18.0...0.17.5)
103
+
104
+ ### Fixed
105
+
106
+ - [#115](https://github.com/axe-api/axe-api/issues/115)
107
+ - [#114](https://github.com/axe-api/axe-api/issues/114)
108
+
109
+ ### Enhancements
110
+
111
+ - [#113](https://github.com/axe-api/axe-api/issues/113)
112
+ - [#107](https://github.com/axe-api/axe-api/issues/107)
113
+ - [#108](https://github.com/axe-api/axe-api/issues/108)
114
+
115
+ ## [0.17.5 (2021-11-27)](https://github.com/axe-api/axe-api/compare/0.17.5...0.17.4)
116
+
117
+ ### Fixed
118
+
119
+ - [#111](https://github.com/axe-api/axe-api/issues/111)
120
+
121
+ ## [0.17.4 (2021-10-28)](https://github.com/axe-api/axe-api/compare/0.17.4...0.17.3)
122
+
123
+ ### Fixed
124
+
125
+ - [#97](https://github.com/axe-api/axe-api/issues/97)
126
+ - [#104](https://github.com/axe-api/axe-api/issues/104)
127
+
128
+ ## [0.17.3 (2021-10-28)](https://github.com/axe-api/axe-api/compare/0.17.3...0.17.2)
129
+
130
+ ### Fixed
131
+
132
+ - [#98](https://github.com/axe-api/axe-api/issues/98)
133
+
134
+ ## [0.17.2 (2021-10-17)](https://github.com/axe-api/axe-api/compare/0.17.2...0.17.1)
135
+
136
+ ### Fixed
137
+
138
+ - Fixed table join on the related table filter.
139
+
140
+ ## [0.17.1 (2021-10-17)](https://github.com/axe-api/axe-api/compare/0.17.1...0.17.0)
141
+
142
+ ### Fixed
143
+
144
+ - Query bug on child models [#93](https://github.com/axe-api/axe-api/issues/93)
145
+
146
+ ## [0.17.0 (2021-10-17)](https://github.com/axe-api/axe-api/compare/0.17.0...0.16.0)
147
+
148
+ ### Fixed
149
+
150
+ - Related query column name check bug has been fixed.
151
+
152
+ ### Features
153
+
154
+ - Global serializer for HTTP results [#37](https://github.com/axe-api/axe-api/issues/37)
155
+
156
+ ## [0.16.0 (2021-10-06)](https://github.com/axe-api/axe-api/compare/0.16.0...0.15.0)
157
+
158
+ ### Features
159
+
160
+ - Fixes [#89](https://github.com/axe-api/axe-api/issues/89)
161
+
162
+ ## [0.15.0 (2021-10-03)](https://github.com/axe-api/axe-api/compare/0.15.0...0.14.1)
163
+
164
+ ### Features
165
+
166
+ - Fixes [#87](https://github.com/axe-api/axe-api/issues/87)
167
+
168
+ ## [0.14.1 (2021-09-20)](https://github.com/axe-api/axe-api/compare/0.14.1...0.14.0)
169
+
170
+ ### Fixed
171
+
172
+ - Fixes [#83](https://github.com/axe-api/axe-api/issues/83)
173
+
174
+ ## [0.14.0 (2021-09-15)](https://github.com/axe-api/axe-api/compare/0.14.0...0.13.3)
175
+
176
+ ### Features
177
+
178
+ - General hooks definition feature has been added. ([#81](https://github.com/axe-api/axe-api/issues/81))
179
+
180
+ ## [0.13.3 (2021-09-15)](https://github.com/axe-api/axe-api/compare/0.13.2...0.13.3)
181
+
182
+ ### Fixed
183
+
184
+ - Fixed CORS bugs.
185
+
186
+ ## [0.13.2 (2021-08-20)](https://github.com/axe-api/axe-api/compare/0.13.1...0.13.2)
187
+
188
+ ### Fixed
189
+
190
+ - Fixes [#27](https://github.com/axe-api/axe-api/issues/27)
191
+ - Fixes [#29](https://github.com/axe-api/axe-api/issues/29)
192
+ - Fixes [#75](https://github.com/axe-api/axe-api/issues/75)
193
+ - Fixes [#78](https://github.com/axe-api/axe-api/issues/78)
194
+
195
+ ## [0.13.1 (2021-08-09)](https://github.com/axe-api/axe-api/compare/0.13.0...0.13.1)
196
+
197
+ ### Fixed
198
+
199
+ - Fixes [#69](https://github.com/axe-api/axe-api/issues/69)
200
+ - Fixes [#70](https://github.com/axe-api/axe-api/issues/70)
201
+ - Fixes [#71](https://github.com/axe-api/axe-api/issues/71)
202
+ - Fixes [#72](https://github.com/axe-api/axe-api/issues/72)
203
+
204
+ ## [0.13.0 (2021-07-25)](https://github.com/axe-api/axe-api/compare/0.12.2...0.13.0)
205
+
206
+ ### Features
207
+
208
+ - PostgreSQL database analyzer and integration tests have been added.
209
+
210
+ ## [0.12.2 (2021-07-24)](https://github.com/axe-api/axe-api/compare/0.12.1...0.12.2)
211
+
212
+ ### Fixed
213
+
214
+ - Throwing an error if the primary key column isn't in the database table bug has been fixed. (#61)[https://github.com/axe-api/axe-api/issues/61]
215
+ - Using numeric column name bug has been fixed. (#24)[https://github.com/axe-api/axe-api/issues/24]
216
+
217
+ ## [0.12.1 (2021-07-24)](https://github.com/axe-api/axe-api/compare/0.12.0...0.12.1)
218
+
219
+ ### Fixed
220
+
221
+ - Fixed security issues.
@@ -3,6 +3,7 @@ declare class SchemaValidatorService {
3
3
  private version;
4
4
  constructor(version: IVersion);
5
5
  validate(): Promise<void>;
6
+ private checkModelReservedKeywordsOrFail;
6
7
  private checkModelColumnsOrFail;
7
8
  private checkRelationNamesOrFail;
8
9
  private getQueryLimitRelations;
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const AxeError_1 = __importDefault(require("../Exceptions/AxeError"));
16
16
  const Enums_1 = require("../Enums");
17
17
  const Services_1 = require("../Services");
18
+ const constants_1 = require("../constants");
18
19
  const COLUMN_BASED_QUERY_LIMITS = [
19
20
  Enums_1.QueryFeature.Sorting,
20
21
  Enums_1.QueryFeature.WhereEqual,
@@ -52,7 +53,7 @@ class SchemaValidatorService {
52
53
  if (!key) {
53
54
  return "";
54
55
  }
55
- const [, field] = key === null || key === void 0 ? void 0 : key.split(".");
56
+ const [, field] = key.split(".");
56
57
  return field;
57
58
  });
58
59
  return items;
@@ -120,6 +121,7 @@ class SchemaValidatorService {
120
121
  return __awaiter(this, void 0, void 0, function* () {
121
122
  const logger = Services_1.LogService.getInstance();
122
123
  this.version.modelList.get().forEach((model) => {
124
+ this.checkModelReservedKeywordsOrFail(model);
123
125
  this.checkModelColumnsOrFail(model, this.getModelFillableColumns(model));
124
126
  this.checkModelColumnsOrFail(model, this.getModelFormValidationColumns(model));
125
127
  this.checkModelColumnsOrFail(model, this.getModelHiddenColumns(model));
@@ -132,6 +134,22 @@ class SchemaValidatorService {
132
134
  logger.info(`[${this.version.name}] Database schema has been validated.`);
133
135
  });
134
136
  }
137
+ checkModelReservedKeywordsOrFail(model) {
138
+ const reservedKeywords = [];
139
+ constants_1.RESERVED_KEYWORDS.forEach((keyword) => {
140
+ if (model.columnNames.includes(keyword) ||
141
+ model.name.toLowerCase().includes(keyword)) {
142
+ reservedKeywords.push(keyword);
143
+ }
144
+ for (const relation of model.relations) {
145
+ if (relation.name === keyword)
146
+ reservedKeywords.push(relation.name);
147
+ }
148
+ });
149
+ if (reservedKeywords.length > 0) {
150
+ throw new Error(`The following keywords are reserved for the framework; "${reservedKeywords.join(",")}"`);
151
+ }
152
+ }
135
153
  checkModelColumnsOrFail(model, modelColumns) {
136
154
  const undefinedColumns = modelColumns.filter((modelColumn) => !model.columnNames.includes(modelColumn));
137
155
  if (undefinedColumns.length > 0) {
@@ -11,6 +11,7 @@ export declare const LOG_COLORS: {
11
11
  fgWhite: string;
12
12
  fgReset: string;
13
13
  };
14
+ export declare const RESERVED_KEYWORDS: string[];
14
15
  export declare const DEFAULT_HANDLERS: HandlerTypes[];
15
16
  export declare const DEFAULT_METHODS_OF_MODELS: string[];
16
17
  export declare const API_ROUTE_TEMPLATES: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_VERSION_CONFIG = exports.RelationQueryFeatureMap = exports.ConditionQueryFeatureMap = exports.API_ROUTE_TEMPLATES = exports.DEFAULT_METHODS_OF_MODELS = exports.DEFAULT_HANDLERS = exports.LOG_COLORS = void 0;
3
+ exports.DEFAULT_VERSION_CONFIG = exports.RelationQueryFeatureMap = exports.ConditionQueryFeatureMap = exports.API_ROUTE_TEMPLATES = exports.DEFAULT_METHODS_OF_MODELS = exports.DEFAULT_HANDLERS = exports.RESERVED_KEYWORDS = exports.LOG_COLORS = void 0;
4
4
  const Enums_1 = require("./Enums");
5
5
  const LimitService_1 = require("./Services/LimitService");
6
6
  exports.LOG_COLORS = {
@@ -14,6 +14,17 @@ exports.LOG_COLORS = {
14
14
  fgWhite: "\x1b[37m",
15
15
  fgReset: "\x1b[0m",
16
16
  };
17
+ exports.RESERVED_KEYWORDS = [
18
+ "force",
19
+ "model",
20
+ "api",
21
+ "routes",
22
+ "docs",
23
+ "hook",
24
+ "hooks",
25
+ "event",
26
+ "events",
27
+ ];
17
28
  exports.DEFAULT_HANDLERS = [
18
29
  Enums_1.HandlerTypes.INSERT,
19
30
  Enums_1.HandlerTypes.PAGINATE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axe-api",
3
- "version": "0.30.0-rc9",
3
+ "version": "0.30.0",
4
4
  "description": "AXE API is a simple tool which has been created based on Express and Knex.js to create Rest APIs quickly.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -10,7 +10,21 @@
10
10
  "directories": {
11
11
  "test": "tests"
12
12
  },
13
- "author": "Özgür Adem Işıklı <i.ozguradem@gmail.com>",
13
+ "contributors": [
14
+ {
15
+ "name": "Alihan Saraç",
16
+ "url": "https://www.linkedin.com/in/alihan-sara%C3%A7-ba75a319a/"
17
+ },
18
+ {
19
+ "name": "Arif Karakılıç",
20
+ "url": "https://www.linkedin.com/in/arif-karak%C4%B1l%C4%B1%C3%A7-992a58150/"
21
+ },
22
+ {
23
+ "name": "Özgür Adem Işıklı",
24
+ "email": "i.ozguradem@gmail.com",
25
+ "url": "https://www.linkedin.com/in/ozguradem"
26
+ }
27
+ ],
14
28
  "license": "MIT",
15
29
  "scripts": {
16
30
  "build": "rm -rf build && tsc && rm -rf build/dev-kit",
@@ -39,13 +53,11 @@
39
53
  "validatorjs": "^3.22.1"
40
54
  },
41
55
  "devDependencies": {
42
- "multer": "^1.4.5-lts.1",
43
- "@types/express": "^4.17.17",
44
- "express": "^4.18.2",
45
56
  "@babel/core": "^7.21.3",
46
57
  "@babel/preset-env": "^7.20.2",
47
58
  "@babel/preset-typescript": "^7.21.0",
48
59
  "@types/accept-language-parser": "^1.5.3",
60
+ "@types/express": "^4.17.17",
49
61
  "@types/multer": "^1.4.7",
50
62
  "@types/pluralize": "^0.0.29",
51
63
  "@types/validatorjs": "^3.15.0",
@@ -59,12 +71,15 @@
59
71
  "eslint-plugin-promise": "^5.1.0",
60
72
  "eslint-plugin-unicorn": "^33.0.1",
61
73
  "eslint-watch": "^7.0.0",
74
+ "express": "^4.18.2",
62
75
  "glob": "^9.3.2",
63
76
  "jest": "^29.5.0",
77
+ "multer": "^1.4.5-lts.1",
64
78
  "mysql": "^2.18.1",
65
79
  "node-color-log": "^10.0.2",
66
80
  "nodemon": "^2.0.22",
67
81
  "pg": "^8.10.0",
82
+ "prettier": "^2.8.6",
68
83
  "set-value": ">=4.1.0",
69
84
  "sqlite3": "^5.1.6",
70
85
  "ts-node": "^10.9.1",
@@ -1 +0,0 @@
1
- export {};
package/build/dev-kit.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_color_log_1 = __importDefault(require("node-color-log"));
7
- const dotenv_1 = __importDefault(require("dotenv"));
8
- const path_1 = __importDefault(require("path"));
9
- const index_1 = require("./index");
10
- node_color_log_1.default.bgColor("yellow").color("black").log("Axe API dev-kit (1.0.0)");
11
- node_color_log_1.default
12
- .color("blue")
13
- .log("Docs: https://axe-api.com/contribution/fundamentals.html \n");
14
- dotenv_1.default.config();
15
- const server = new index_1.Server();
16
- server.start(path_1.default.join(__dirname, "dev-kit"));