axe-api 0.30.0-rc9 → 0.30.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 ADDED
@@ -0,0 +1,227 @@
1
+ # Release Notes
2
+
3
+ ## [0.30.1 (2023-04-15)](https://github.com/axe-api/axe-api/compare/0.30.1...0.30.0)
4
+
5
+ ### Fixed
6
+
7
+ - Fixed URL slash character difference between windows and *nix [#164](https://github.com/axe-api/axe-api/issues/164)
8
+
9
+ ## [0.30.0 (2023-04-05)](https://github.com/axe-api/axe-api/compare/0.30.0...0.22.0)
10
+
11
+ ### Breaking Changes
12
+
13
+ - Added new Serizaliation folder [#125](https://github.com/axe-api/axe-api/issues/125)
14
+ - New hook/event folder structure [#146](https://github.com/axe-api/axe-api/issues/146)
15
+ - Limiting query features by configurations [#38](https://github.com/axe-api/axe-api/issues/38)
16
+ - Removing external dependencies from axe-core [#151](https://github.com/axe-api/axe-api/issues/151)
17
+
18
+ ## [0.22.0 (2023-01-29)](https://github.com/axe-api/axe-api/compare/0.22.0...0.21.0)
19
+
20
+ ### Features
21
+
22
+ - Added Soft-Deleting feature [#41](https://github.com/axe-api/axe-api/issues/41)
23
+
24
+ ### Fixed
25
+
26
+ - Fixed model relation route URLs [#141](https://github.com/axe-api/axe-api/issues/141)
27
+
28
+ ## [0.21.0 (2022-12-28)](https://github.com/axe-api/axe-api/compare/0.21.0...0.20.4)
29
+
30
+ ### Features
31
+
32
+ - Added `i18n` support. [#44](https://github.com/axe-api/axe-api/issues/44)
33
+
34
+ ## [0.20.4 (2022-12-24)](https://github.com/axe-api/axe-api/compare/0.20.4...0.20.3)
35
+
36
+ ### Fixed
37
+
38
+ - Fixed [#124](https://github.com/axe-api/axe-api/issues/124)
39
+ - Throwing errors in the `development` environment has been fixed.
40
+ - Unbuilt integration test issue has been fixed.
41
+
42
+ ## [0.20.3 (2022-12-24)](https://github.com/axe-api/axe-api/compare/0.20.3...0.20.0)
43
+
44
+ ### Fixed
45
+
46
+ - NPM publish bugs
47
+
48
+ ## [0.20.0 (2022-12-24)](https://github.com/axe-api/axe-api/compare/0.20.0...0.19.2)
49
+
50
+ 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`.
51
+
52
+ ### Breaking Changes
53
+
54
+ #### Naming Changes
55
+
56
+ - File extensions: `User.js` to `User.ts`
57
+ - `LOG_LEVELS` constant variable has been changed with `LogLevels` enum.
58
+ - `HANDLERS` constant variable has been changed with `HandlerTypes` enum.
59
+ - `IoC` service has been renamed as `IoCService`.
60
+ - Hooks and Event files' names should be singular;
61
+ - `UserHooks.js` => `UserHook.ts`
62
+ - `UserEvents.js` => `UserEvent.ts`
63
+
64
+ #### Interface Changes
65
+
66
+ - `validations()` getter should return `IMethodBaseValidations` interface.
67
+ - In hook functions, `IHookParameter` interface should be used as the parameter type.
68
+ - Init functions (`onBeforeInit`, `onAfterInit`) should be use the `Express` type;
69
+ - `const onBeforeInit = async ({ app }) => {` => `const onBeforeInit = async (app: Express) => {`
70
+ - `const onAfterInit = async ({ app }) => {` => `const onAfterInit = async (app: Express) => {`
71
+ - Application config should be implemented `IApplicationConfig` interface.
72
+
73
+ #### Implementation Changes
74
+
75
+ - Starting server part has been changed;
76
+ - `const server = new Server(appFolder)` => `const server = new Server()`
77
+ - `server.listen()` => `server.start(__dirname);`
78
+ - `knexfile.js` should not use the `app/Application/Config.js` anymore.
79
+
80
+ ## [0.19.2 (2022-01-22)](https://github.com/axe-api/axe-api/compare/0.19.2...0.19.1)
81
+
82
+ ### Fixed
83
+
84
+ - Fixed the calling `onBeforePaginate` and `onBeforeShow` hooks bug.
85
+
86
+ ## [0.19.1 (2022-01-22)](https://github.com/axe-api/axe-api/compare/0.19.1...0.19.0)
87
+
88
+ ### Fixed
89
+
90
+ - knex.js version update.
91
+
92
+ ## [0.19.0 (2021-12-05)](https://github.com/axe-api/axe-api/compare/0.19.0...0.18.1)
93
+
94
+ ### Fixed
95
+
96
+ - [#110](https://github.com/axe-api/axe-api/issues/110)
97
+
98
+ ### Enhancements
99
+
100
+ - [#106](https://github.com/axe-api/axe-api/issues/106)
101
+
102
+ ## [0.18.1 (2021-12-02)](https://github.com/axe-api/axe-api/compare/0.18.1...0.18.0)
103
+
104
+ ### Fixed
105
+
106
+ - [#117](https://github.com/axe-api/axe-api/issues/117)
107
+
108
+ ## [0.18.0 (2021-11-30)](https://github.com/axe-api/axe-api/compare/0.18.0...0.17.5)
109
+
110
+ ### Fixed
111
+
112
+ - [#115](https://github.com/axe-api/axe-api/issues/115)
113
+ - [#114](https://github.com/axe-api/axe-api/issues/114)
114
+
115
+ ### Enhancements
116
+
117
+ - [#113](https://github.com/axe-api/axe-api/issues/113)
118
+ - [#107](https://github.com/axe-api/axe-api/issues/107)
119
+ - [#108](https://github.com/axe-api/axe-api/issues/108)
120
+
121
+ ## [0.17.5 (2021-11-27)](https://github.com/axe-api/axe-api/compare/0.17.5...0.17.4)
122
+
123
+ ### Fixed
124
+
125
+ - [#111](https://github.com/axe-api/axe-api/issues/111)
126
+
127
+ ## [0.17.4 (2021-10-28)](https://github.com/axe-api/axe-api/compare/0.17.4...0.17.3)
128
+
129
+ ### Fixed
130
+
131
+ - [#97](https://github.com/axe-api/axe-api/issues/97)
132
+ - [#104](https://github.com/axe-api/axe-api/issues/104)
133
+
134
+ ## [0.17.3 (2021-10-28)](https://github.com/axe-api/axe-api/compare/0.17.3...0.17.2)
135
+
136
+ ### Fixed
137
+
138
+ - [#98](https://github.com/axe-api/axe-api/issues/98)
139
+
140
+ ## [0.17.2 (2021-10-17)](https://github.com/axe-api/axe-api/compare/0.17.2...0.17.1)
141
+
142
+ ### Fixed
143
+
144
+ - Fixed table join on the related table filter.
145
+
146
+ ## [0.17.1 (2021-10-17)](https://github.com/axe-api/axe-api/compare/0.17.1...0.17.0)
147
+
148
+ ### Fixed
149
+
150
+ - Query bug on child models [#93](https://github.com/axe-api/axe-api/issues/93)
151
+
152
+ ## [0.17.0 (2021-10-17)](https://github.com/axe-api/axe-api/compare/0.17.0...0.16.0)
153
+
154
+ ### Fixed
155
+
156
+ - Related query column name check bug has been fixed.
157
+
158
+ ### Features
159
+
160
+ - Global serializer for HTTP results [#37](https://github.com/axe-api/axe-api/issues/37)
161
+
162
+ ## [0.16.0 (2021-10-06)](https://github.com/axe-api/axe-api/compare/0.16.0...0.15.0)
163
+
164
+ ### Features
165
+
166
+ - Fixes [#89](https://github.com/axe-api/axe-api/issues/89)
167
+
168
+ ## [0.15.0 (2021-10-03)](https://github.com/axe-api/axe-api/compare/0.15.0...0.14.1)
169
+
170
+ ### Features
171
+
172
+ - Fixes [#87](https://github.com/axe-api/axe-api/issues/87)
173
+
174
+ ## [0.14.1 (2021-09-20)](https://github.com/axe-api/axe-api/compare/0.14.1...0.14.0)
175
+
176
+ ### Fixed
177
+
178
+ - Fixes [#83](https://github.com/axe-api/axe-api/issues/83)
179
+
180
+ ## [0.14.0 (2021-09-15)](https://github.com/axe-api/axe-api/compare/0.14.0...0.13.3)
181
+
182
+ ### Features
183
+
184
+ - General hooks definition feature has been added. ([#81](https://github.com/axe-api/axe-api/issues/81))
185
+
186
+ ## [0.13.3 (2021-09-15)](https://github.com/axe-api/axe-api/compare/0.13.2...0.13.3)
187
+
188
+ ### Fixed
189
+
190
+ - Fixed CORS bugs.
191
+
192
+ ## [0.13.2 (2021-08-20)](https://github.com/axe-api/axe-api/compare/0.13.1...0.13.2)
193
+
194
+ ### Fixed
195
+
196
+ - Fixes [#27](https://github.com/axe-api/axe-api/issues/27)
197
+ - Fixes [#29](https://github.com/axe-api/axe-api/issues/29)
198
+ - Fixes [#75](https://github.com/axe-api/axe-api/issues/75)
199
+ - Fixes [#78](https://github.com/axe-api/axe-api/issues/78)
200
+
201
+ ## [0.13.1 (2021-08-09)](https://github.com/axe-api/axe-api/compare/0.13.0...0.13.1)
202
+
203
+ ### Fixed
204
+
205
+ - Fixes [#69](https://github.com/axe-api/axe-api/issues/69)
206
+ - Fixes [#70](https://github.com/axe-api/axe-api/issues/70)
207
+ - Fixes [#71](https://github.com/axe-api/axe-api/issues/71)
208
+ - Fixes [#72](https://github.com/axe-api/axe-api/issues/72)
209
+
210
+ ## [0.13.0 (2021-07-25)](https://github.com/axe-api/axe-api/compare/0.12.2...0.13.0)
211
+
212
+ ### Features
213
+
214
+ - PostgreSQL database analyzer and integration tests have been added.
215
+
216
+ ## [0.12.2 (2021-07-24)](https://github.com/axe-api/axe-api/compare/0.12.1...0.12.2)
217
+
218
+ ### Fixed
219
+
220
+ - 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]
221
+ - Using numeric column name bug has been fixed. (#24)[https://github.com/axe-api/axe-api/issues/24]
222
+
223
+ ## [0.12.1 (2021-07-24)](https://github.com/axe-api/axe-api/compare/0.12.0...0.12.1)
224
+
225
+ ### Fixed
226
+
227
+ - Fixed security issues.
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const pluralize_1 = __importDefault(require("pluralize"));
16
- const path_1 = __importDefault(require("path"));
17
16
  const change_case_1 = require("change-case");
18
17
  const Resolvers_1 = require("../Resolvers");
19
18
  const constants_1 = require("../constants");
@@ -78,7 +77,7 @@ class RouterBuilder {
78
77
  continue;
79
78
  }
80
79
  const urlCreator = constants_1.API_ROUTE_TEMPLATES[handlerType];
81
- const url = urlCreator(path_1.default.join(yield this.getRootPrefix(), this.version.name), urlPrefix, resource, model.instance.primaryKey);
80
+ const url = urlCreator(`${yield this.getRootPrefix()}/${this.version.name}`, urlPrefix, resource, model.instance.primaryKey);
82
81
  // Creating the middleware list for the route. As default, we support some
83
82
  // internal middlewares such as `Accept Language Middleware` which parse
84
83
  // the "accept-language" header to use in the application general.
@@ -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.1",
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"));