axe-api 0.20.0-rc9 → 0.20.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 +182 -0
- package/package.json +66 -65
- package/readme.md +174 -152
- package/build/index.d.ts +0 -7
- package/build/index.js +0 -30
- package/build/src/Builders/ModelTreeBuilder.d.ts +0 -9
- package/build/src/Builders/ModelTreeBuilder.js +0 -64
- package/build/src/Builders/RouterBuilder.d.ts +0 -15
- package/build/src/Builders/RouterBuilder.js +0 -219
- package/build/src/Builders/index.d.ts +0 -3
- package/build/src/Builders/index.js +0 -10
- package/build/src/Enums.d.ts +0 -77
- package/build/src/Enums.js +0 -90
- package/build/src/Exceptions/ApiError.d.ts +0 -8
- package/build/src/Exceptions/ApiError.js +0 -12
- package/build/src/Handlers/AllHandler.d.ts +0 -4
- package/build/src/Handlers/AllHandler.js +0 -44
- package/build/src/Handlers/DestroyHandler.d.ts +0 -4
- package/build/src/Handlers/DestroyHandler.js +0 -37
- package/build/src/Handlers/HandlerFactory.d.ts +0 -6
- package/build/src/Handlers/HandlerFactory.js +0 -36
- package/build/src/Handlers/Helpers.d.ts +0 -14
- package/build/src/Handlers/Helpers.js +0 -231
- package/build/src/Handlers/PaginateHandler.d.ts +0 -4
- package/build/src/Handlers/PaginateHandler.js +0 -48
- package/build/src/Handlers/PatchHandler.d.ts +0 -4
- package/build/src/Handlers/PatchHandler.js +0 -62
- package/build/src/Handlers/ShowHandler.d.ts +0 -4
- package/build/src/Handlers/ShowHandler.js +0 -51
- package/build/src/Handlers/StoreHandler.d.ts +0 -4
- package/build/src/Handlers/StoreHandler.js +0 -59
- package/build/src/Handlers/UpdateHandler.d.ts +0 -4
- package/build/src/Handlers/UpdateHandler.js +0 -62
- package/build/src/Interfaces.d.ts +0 -165
- package/build/src/Interfaces.js +0 -3
- package/build/src/Model.d.ts +0 -24
- package/build/src/Model.js +0 -108
- package/build/src/Resolvers/FileResolver.d.ts +0 -5
- package/build/src/Resolvers/FileResolver.js +0 -76
- package/build/src/Resolvers/FolderResolver.d.ts +0 -5
- package/build/src/Resolvers/FolderResolver.js +0 -19
- package/build/src/Resolvers/GeneralHookResolver.d.ts +0 -5
- package/build/src/Resolvers/GeneralHookResolver.js +0 -35
- package/build/src/Resolvers/ModelMiddlewareResolver.d.ts +0 -7
- package/build/src/Resolvers/ModelMiddlewareResolver.js +0 -29
- package/build/src/Resolvers/ModelResolver.d.ts +0 -9
- package/build/src/Resolvers/ModelResolver.js +0 -101
- package/build/src/Resolvers/TransactionResolver.d.ts +0 -8
- package/build/src/Resolvers/TransactionResolver.js +0 -75
- package/build/src/Resolvers/index.d.ts +0 -7
- package/build/src/Resolvers/index.js +0 -18
- package/build/src/Server.d.ts +0 -8
- package/build/src/Server.js +0 -101
- package/build/src/Services/DocumentationService.d.ts +0 -9
- package/build/src/Services/DocumentationService.js +0 -22
- package/build/src/Services/IoCService.d.ts +0 -9
- package/build/src/Services/IoCService.js +0 -51
- package/build/src/Services/LogService.d.ts +0 -12
- package/build/src/Services/LogService.js +0 -41
- package/build/src/Services/ModelListService.d.ts +0 -8
- package/build/src/Services/ModelListService.js +0 -18
- package/build/src/Services/ModelService.d.ts +0 -20
- package/build/src/Services/ModelService.js +0 -38
- package/build/src/Services/QueryService.d.ts +0 -39
- package/build/src/Services/QueryService.js +0 -447
- package/build/src/Services/SchemaValidatorService.d.ts +0 -12
- package/build/src/Services/SchemaValidatorService.js +0 -114
- package/build/src/Services/index.d.ts +0 -8
- package/build/src/Services/index.js +0 -20
- package/build/src/constants.d.ts +0 -23
- package/build/src/constants.js +0 -62
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Release Notes
|
|
2
|
+
|
|
3
|
+
## [0.20.0 (2022-12-24)](https://github.com/axe-api/axe-api/compare/0.20.0...0.19.2)
|
|
4
|
+
|
|
5
|
+
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`.
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
#### Naming Changes
|
|
10
|
+
|
|
11
|
+
- File extensions: `User.js` to `User.ts`
|
|
12
|
+
- `LOG_LEVELS` constant variable has been changed with `LogLevels` enum.
|
|
13
|
+
- `HANDLERS` constant variable has been changed with `HandlerTypes` enum.
|
|
14
|
+
- `IoC` service has been renamed as `IoCService`.
|
|
15
|
+
- Hooks and Event files' names should be singular;
|
|
16
|
+
- `UserHooks.js` => `UserHook.ts`
|
|
17
|
+
- `UserEvents.js` => `UserEvent.ts`
|
|
18
|
+
|
|
19
|
+
#### Interface Changes
|
|
20
|
+
|
|
21
|
+
- `validations()` getter should return `IMethodBaseValidations` interface.
|
|
22
|
+
- In hook functions, `IHookParameter` interface should be used as the parameter type.
|
|
23
|
+
- Init functions (`onBeforeInit`, `onAfterInit`) should be use the `Express` type;
|
|
24
|
+
- `const onBeforeInit = async ({ app }) => {` => `const onBeforeInit = async (app: Express) => {`
|
|
25
|
+
- `const onAfterInit = async ({ app }) => {` => `const onAfterInit = async (app: Express) => {`
|
|
26
|
+
- Application config should be implemented `IApplicationConfig` interface.
|
|
27
|
+
|
|
28
|
+
#### Implementation Changes
|
|
29
|
+
|
|
30
|
+
- Starting server part has been changed;
|
|
31
|
+
- `const server = new Server(appFolder)` => `const server = new Server()`
|
|
32
|
+
- `server.listen()` => `server.start(__dirname);`
|
|
33
|
+
- `knexfile.js` should not use the `app/Application/Config.js` anymore.
|
|
34
|
+
|
|
35
|
+
## [0.19.2 (2022-01-22)](https://github.com/axe-api/axe-api/compare/0.19.2...0.19.1)
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- Fixed the calling `onBeforePaginate` and `onBeforeShow` hooks bug.
|
|
40
|
+
|
|
41
|
+
## [0.19.1 (2022-01-22)](https://github.com/axe-api/axe-api/compare/0.19.1...0.19.0)
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- knex.js version update.
|
|
46
|
+
|
|
47
|
+
## [0.19.0 (2021-12-05)](https://github.com/axe-api/axe-api/compare/0.19.0...0.18.1)
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
|
|
51
|
+
- [#110](https://github.com/axe-api/axe-api/issues/110)
|
|
52
|
+
|
|
53
|
+
### Enhancements
|
|
54
|
+
|
|
55
|
+
- [#106](https://github.com/axe-api/axe-api/issues/106)
|
|
56
|
+
|
|
57
|
+
## [0.18.1 (2021-12-02)](https://github.com/axe-api/axe-api/compare/0.18.1...0.18.0)
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- [#117](https://github.com/axe-api/axe-api/issues/117)
|
|
62
|
+
|
|
63
|
+
## [0.18.0 (2021-11-30)](https://github.com/axe-api/axe-api/compare/0.18.0...0.17.5)
|
|
64
|
+
|
|
65
|
+
### Fixed
|
|
66
|
+
|
|
67
|
+
- [#115](https://github.com/axe-api/axe-api/issues/115)
|
|
68
|
+
- [#114](https://github.com/axe-api/axe-api/issues/114)
|
|
69
|
+
|
|
70
|
+
### Enhancements
|
|
71
|
+
|
|
72
|
+
- [#113](https://github.com/axe-api/axe-api/issues/113)
|
|
73
|
+
- [#107](https://github.com/axe-api/axe-api/issues/107)
|
|
74
|
+
- [#108](https://github.com/axe-api/axe-api/issues/108)
|
|
75
|
+
|
|
76
|
+
## [0.17.5 (2021-11-27)](https://github.com/axe-api/axe-api/compare/0.17.5...0.17.4)
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
|
|
80
|
+
- [#111](https://github.com/axe-api/axe-api/issues/111)
|
|
81
|
+
|
|
82
|
+
## [0.17.4 (2021-10-28)](https://github.com/axe-api/axe-api/compare/0.17.4...0.17.3)
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
|
|
86
|
+
- [#97](https://github.com/axe-api/axe-api/issues/97)
|
|
87
|
+
- [#104](https://github.com/axe-api/axe-api/issues/104)
|
|
88
|
+
|
|
89
|
+
## [0.17.3 (2021-10-28)](https://github.com/axe-api/axe-api/compare/0.17.3...0.17.2)
|
|
90
|
+
|
|
91
|
+
### Fixed
|
|
92
|
+
|
|
93
|
+
- [#98](https://github.com/axe-api/axe-api/issues/98)
|
|
94
|
+
|
|
95
|
+
## [0.17.2 (2021-10-17)](https://github.com/axe-api/axe-api/compare/0.17.2...0.17.1)
|
|
96
|
+
|
|
97
|
+
### Fixed
|
|
98
|
+
|
|
99
|
+
- Fixed table join on the related table filter.
|
|
100
|
+
|
|
101
|
+
## [0.17.1 (2021-10-17)](https://github.com/axe-api/axe-api/compare/0.17.1...0.17.0)
|
|
102
|
+
|
|
103
|
+
### Fixed
|
|
104
|
+
|
|
105
|
+
- Query bug on child models [#93](https://github.com/axe-api/axe-api/issues/93)
|
|
106
|
+
|
|
107
|
+
## [0.17.0 (2021-10-17)](https://github.com/axe-api/axe-api/compare/0.17.0...0.16.0)
|
|
108
|
+
|
|
109
|
+
### Fixed
|
|
110
|
+
|
|
111
|
+
- Related query column name check bug has been fixed.
|
|
112
|
+
|
|
113
|
+
### Features
|
|
114
|
+
|
|
115
|
+
- Global serializer for HTTP results [#37](https://github.com/axe-api/axe-api/issues/37)
|
|
116
|
+
|
|
117
|
+
## [0.16.0 (2021-10-06)](https://github.com/axe-api/axe-api/compare/0.16.0...0.15.0)
|
|
118
|
+
|
|
119
|
+
### Features
|
|
120
|
+
|
|
121
|
+
- Fixes [#89](https://github.com/axe-api/axe-api/issues/89)
|
|
122
|
+
|
|
123
|
+
## [0.15.0 (2021-10-03)](https://github.com/axe-api/axe-api/compare/0.15.0...0.14.1)
|
|
124
|
+
|
|
125
|
+
### Features
|
|
126
|
+
|
|
127
|
+
- Fixes [#87](https://github.com/axe-api/axe-api/issues/87)
|
|
128
|
+
|
|
129
|
+
## [0.14.1 (2021-09-20)](https://github.com/axe-api/axe-api/compare/0.14.1...0.14.0)
|
|
130
|
+
|
|
131
|
+
### Fixed
|
|
132
|
+
|
|
133
|
+
- Fixes [#83](https://github.com/axe-api/axe-api/issues/83)
|
|
134
|
+
|
|
135
|
+
## [0.14.0 (2021-09-15)](https://github.com/axe-api/axe-api/compare/0.14.0...0.13.3)
|
|
136
|
+
|
|
137
|
+
### Features
|
|
138
|
+
|
|
139
|
+
- General hooks definition feature has been added. ([#81](https://github.com/axe-api/axe-api/issues/81))
|
|
140
|
+
|
|
141
|
+
## [0.13.3 (2021-09-15)](https://github.com/axe-api/axe-api/compare/0.13.2...0.13.3)
|
|
142
|
+
|
|
143
|
+
### Fixed
|
|
144
|
+
|
|
145
|
+
- Fixed CORS bugs.
|
|
146
|
+
|
|
147
|
+
## [0.13.2 (2021-08-20)](https://github.com/axe-api/axe-api/compare/0.13.1...0.13.2)
|
|
148
|
+
|
|
149
|
+
### Fixed
|
|
150
|
+
|
|
151
|
+
- Fixes [#27](https://github.com/axe-api/axe-api/issues/27)
|
|
152
|
+
- Fixes [#29](https://github.com/axe-api/axe-api/issues/29)
|
|
153
|
+
- Fixes [#75](https://github.com/axe-api/axe-api/issues/75)
|
|
154
|
+
- Fixes [#78](https://github.com/axe-api/axe-api/issues/78)
|
|
155
|
+
|
|
156
|
+
## [0.13.1 (2021-08-09)](https://github.com/axe-api/axe-api/compare/0.13.0...0.13.1)
|
|
157
|
+
|
|
158
|
+
### Fixed
|
|
159
|
+
|
|
160
|
+
- Fixes [#69](https://github.com/axe-api/axe-api/issues/69)
|
|
161
|
+
- Fixes [#70](https://github.com/axe-api/axe-api/issues/70)
|
|
162
|
+
- Fixes [#71](https://github.com/axe-api/axe-api/issues/71)
|
|
163
|
+
- Fixes [#72](https://github.com/axe-api/axe-api/issues/72)
|
|
164
|
+
|
|
165
|
+
## [0.13.0 (2021-07-25)](https://github.com/axe-api/axe-api/compare/0.12.2...0.13.0)
|
|
166
|
+
|
|
167
|
+
### Features
|
|
168
|
+
|
|
169
|
+
- PostgreSQL database analyzer and integration tests have been added.
|
|
170
|
+
|
|
171
|
+
## [0.12.2 (2021-07-24)](https://github.com/axe-api/axe-api/compare/0.12.1...0.12.2)
|
|
172
|
+
|
|
173
|
+
### Fixed
|
|
174
|
+
|
|
175
|
+
- 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]
|
|
176
|
+
- Using numeric column name bug has been fixed. (#24)[https://github.com/axe-api/axe-api/issues/24]
|
|
177
|
+
|
|
178
|
+
## [0.12.1 (2021-07-24)](https://github.com/axe-api/axe-api/compare/0.12.0...0.12.1)
|
|
179
|
+
|
|
180
|
+
### Fixed
|
|
181
|
+
|
|
182
|
+
- Fixed security issues.
|
package/package.json
CHANGED
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "axe-api",
|
|
3
|
-
"version": "0.20.0
|
|
4
|
-
"description": "AXE API is a simple tool which has been created based on Express and Knex.js to create Rest APIs quickly.",
|
|
5
|
-
"main": "build/index.js",
|
|
6
|
-
"types": "build/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"/build"
|
|
9
|
-
],
|
|
10
|
-
"directories": {
|
|
11
|
-
"test": "tests"
|
|
12
|
-
},
|
|
13
|
-
"author": "Özgür Adem Işıklı <i.ozguradem@gmail.com>",
|
|
14
|
-
"license": "
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "tsc",
|
|
17
|
-
"build:watch": "tsc -w",
|
|
18
|
-
"dev": "ts-node-dev --respawn --clear index.ts",
|
|
19
|
-
"test": "jest --runInBand",
|
|
20
|
-
"test:dev": "jest --watch",
|
|
21
|
-
"lint": "eslint src/**",
|
|
22
|
-
"lint:watch": "esw --watch --color",
|
|
23
|
-
"
|
|
24
|
-
"test:integration:
|
|
25
|
-
"test:integration:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"knex
|
|
35
|
-
"knex-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"@babel/core": "^7.
|
|
42
|
-
"@babel/
|
|
43
|
-
"@babel/preset-
|
|
44
|
-
"@
|
|
45
|
-
"@types/
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"babel-
|
|
49
|
-
"
|
|
50
|
-
"eslint": "^
|
|
51
|
-
"eslint-
|
|
52
|
-
"eslint-plugin-
|
|
53
|
-
"eslint-plugin-
|
|
54
|
-
"eslint-plugin-
|
|
55
|
-
"eslint-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "axe-api",
|
|
3
|
+
"version": "0.20.0",
|
|
4
|
+
"description": "AXE API is a simple tool which has been created based on Express and Knex.js to create Rest APIs quickly.",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/build"
|
|
9
|
+
],
|
|
10
|
+
"directories": {
|
|
11
|
+
"test": "tests"
|
|
12
|
+
},
|
|
13
|
+
"author": "Özgür Adem Işıklı <i.ozguradem@gmail.com>",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"build:watch": "tsc -w",
|
|
18
|
+
"dev": "ts-node-dev --respawn --clear index.ts",
|
|
19
|
+
"test": "jest --runInBand",
|
|
20
|
+
"test:dev": "jest --watch",
|
|
21
|
+
"lint": "eslint src/**",
|
|
22
|
+
"lint:watch": "esw --watch --color",
|
|
23
|
+
"prepare:integration": "nodemon --ignore \"./tests/**\" ./scripts/run-integration-test.js",
|
|
24
|
+
"test:integration:mysql8": "cd ./tests/integrations && node index.js mysql8",
|
|
25
|
+
"test:integration:mysql57": "cd ./tests/integrations && node index.js mysql57",
|
|
26
|
+
"test:integration:postgres": "cd ./tests/integrations && node index.js postgres"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@types/express": "^4.17.15",
|
|
30
|
+
"change-case": "^4.1.2",
|
|
31
|
+
"dotenv": "^14.2.0",
|
|
32
|
+
"express": "^4.18.2",
|
|
33
|
+
"http-status-codes": "^2.2.0",
|
|
34
|
+
"knex": "^2.3.0",
|
|
35
|
+
"knex-paginate": "^3.0.2",
|
|
36
|
+
"knex-schema-inspector": "^2.0.4",
|
|
37
|
+
"pluralize": "^8.0.0",
|
|
38
|
+
"validatorjs": "^3.22.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@babel/core": "^7.19.1",
|
|
42
|
+
"@babel/preset-env": "^7.19.1",
|
|
43
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
44
|
+
"@types/pluralize": "^0.0.29",
|
|
45
|
+
"@types/validatorjs": "^3.15.0",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
|
47
|
+
"@typescript-eslint/parser": "^5.37.0",
|
|
48
|
+
"babel-jest": "^29.0.3",
|
|
49
|
+
"eslint": "^7.32.0",
|
|
50
|
+
"eslint-config-standard": "^16.0.3",
|
|
51
|
+
"eslint-plugin-import": "^2.25.4",
|
|
52
|
+
"eslint-plugin-node": "^11.1.0",
|
|
53
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
54
|
+
"eslint-plugin-unicorn": "^33.0.1",
|
|
55
|
+
"eslint-watch": "^7.0.0",
|
|
56
|
+
"glob": "^8.0.3",
|
|
57
|
+
"jest": "^29.0.3",
|
|
58
|
+
"mysql": "^2.18.1",
|
|
59
|
+
"nodemon": "^2.0.15",
|
|
60
|
+
"pg": "^8.7.1",
|
|
61
|
+
"set-value": ">=4.1.0",
|
|
62
|
+
"sqlite3": "^5.0.2",
|
|
63
|
+
"ts-node": "^10.9.1",
|
|
64
|
+
"typescript": "^4.8.3"
|
|
65
|
+
}
|
|
66
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,152 +1,174 @@
|
|
|
1
|
-
<h1 align="center">
|
|
2
|
-
<br>
|
|
3
|
-
<a href="https://axe-api.github.io/">
|
|
4
|
-
<img src="https://axe-api.github.io/
|
|
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-publish.yml" target="_blank">
|
|
13
|
-
<img src="https://github.com/axe-api/axe-api/actions/workflows/npm-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
|
-
|
|
27
|
-
|
|
28
|
-
> Axe API has great documentation. Please [check it out in here](https://axe-api.github.io/).
|
|
29
|
-
|
|
30
|
-
## What Is Axe API?
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
##
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<br>
|
|
3
|
+
<a href="https://axe-api.github.io/">
|
|
4
|
+
<img src="https://axe-api.github.io/axe.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-publish.yml" target="_blank">
|
|
13
|
+
<img src="https://github.com/axe-api/axe-api/actions/workflows/npm-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
|
+
Next Generation Rest API Framework
|
|
27
|
+
|
|
28
|
+
> Axe API has great documentation. Please [check it out in here](https://axe-api.github.io/).
|
|
29
|
+
|
|
30
|
+
## What Is Axe API?
|
|
31
|
+
|
|
32
|
+
Axe API is a [Node.js](https://nodejs.org/) framework that helps you create a **Rest API** in a declarative way quickly. :axe:
|
|
33
|
+
|
|
34
|
+
It has been written with [TypeScript](https://www.typescriptlang.org/) and built on [Express](https://expressjs.com/) and [Knex.js](https://knexjs.org/).
|
|
35
|
+
|
|
36
|
+
## Motivation
|
|
37
|
+
|
|
38
|
+
You would understand easily what you are going to code when you look at a bunch of database tables and their relations with each other, more or less. Because, as a developer, you already know that _Rest API_ best practices.
|
|
39
|
+
|
|
40
|
+
Therefore I asked a simple question more than two years ago;
|
|
41
|
+
|
|
42
|
+
**_"Can we create a Rest API in a declarative way, and handle all endpoints automatically?"_**
|
|
43
|
+
|
|
44
|
+
As a result of our work, we have a framework called Axe API that provides a solution to analyze your API definitions and handle all of the endpoints.
|
|
45
|
+
|
|
46
|
+
Basically, you define your models which are your API definitions, and Axe API analyzes them and processes all of your endpoints instead of you.
|
|
47
|
+
|
|
48
|
+
## Showcase
|
|
49
|
+
|
|
50
|
+
Let's look at an example!
|
|
51
|
+
|
|
52
|
+
You have two database tables; `users` and `posts`. These tables are related to each other and we aim that create a **Rest API** for basic **CRUD** endpoints.
|
|
53
|
+
|
|
54
|
+
The only thing to do is creating models like the following example;
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
class User extends Model {
|
|
58
|
+
get fillable(): string[] {
|
|
59
|
+
return ["email", "name", "surname"];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
posts(): IRelation {
|
|
63
|
+
return this.hasMany("Post", "id", "user_id");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
class Post extends Model {
|
|
70
|
+
get fillable(): string[] {
|
|
71
|
+
return ["title", "description"];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
user(): IRelation {
|
|
75
|
+
return this.belongsTo("User", "user_id", "id");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Tada! :tada:
|
|
81
|
+
|
|
82
|
+
Your API is ready to process all of the following endpoints after those model definitions are done.
|
|
83
|
+
|
|
84
|
+
- [GET] `api/users`
|
|
85
|
+
- [POST] `api/users`
|
|
86
|
+
- [GET] `api/users/:id`
|
|
87
|
+
- [PUT] `api/users/:id`
|
|
88
|
+
- [DELETE] `api/users/:id`
|
|
89
|
+
- [GET] `api/users/:userId/posts`
|
|
90
|
+
- [POST] `api/users/:userId/posts`
|
|
91
|
+
- [GET] `api/users/:userId/posts/:id`
|
|
92
|
+
- [PUT] `api/users/:userId/posts/:id`
|
|
93
|
+
- [DELETE] `api/users/:userId/posts/:id`
|
|
94
|
+
|
|
95
|
+
This is the main power of Axe API. Nevertheless, it is not limited only to this power. There are many more features are waiting to discover. :bulb:
|
|
96
|
+
|
|
97
|
+
## Installation
|
|
98
|
+
|
|
99
|
+
Using **Axe API** in an application is very easy. We've created a CLI tool for you; [axe-magic](https://github.com/axe-api/axe-magic).
|
|
100
|
+
|
|
101
|
+
You can create a new Axe API project by using [axe-magic](https://github.com/axe-api/axe-magic). But first, you can install it in your development environment. When you installed it, you can be able to access **axe-magic** command via CLI. You can use the following command to install **axe-magic** to your machine;
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
$ npm i -g axe-magic
|
|
105
|
+
$ axe-magic --version
|
|
106
|
+
1.0.0
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
After that, creating a new project is very easy. Just you can execute the following command;
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
$ axe-magic new my-api
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This command will pull [axe-api-template](https://github.com/axe-api/axe-api-template) project to your current directory with a new name, **my-api**.
|
|
116
|
+
|
|
117
|
+
To install your project's depencies, you can execute the following commands in the root directory;
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
$ cd my-api
|
|
121
|
+
$ npm install
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
To serve this application, you can execute the following command;
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
$ npm run start:dev
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
After that, your first **Axe API** application will be running in `localhost:3000`.
|
|
131
|
+
|
|
132
|
+
You will see the following API response if you visit [localhost:3000](http://localhost:3000).
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"name": "AXE API",
|
|
137
|
+
"description": "The best API creation tool in the world.",
|
|
138
|
+
"aim": "To kill them all!"
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
If you can see that response, it means that your project is running properly.
|
|
143
|
+
|
|
144
|
+
## Documentation
|
|
145
|
+
|
|
146
|
+
Axe API has great documentation. Please [check it out in here](https://axe-api.github.io/).
|
|
147
|
+
|
|
148
|
+
## How To Run Integration Tests
|
|
149
|
+
|
|
150
|
+
> You have to have **Docker** and **Docker Compose** on your local development environment to run integration tests.
|
|
151
|
+
|
|
152
|
+
Execute the following commands to prepare the integration app
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
cd tests/integrations && npm install && npm ci && npm run build --if-present
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Execute the following commands to prepare the database;
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
docker-compose -f "./tests/integrations/docker-compose.mysql8.yml" up -d --build
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
> To down the database, you can use the following command; `docker-compose -f "./tests/integrations/docker-compose.mysql8.yml" up -d --build`
|
|
165
|
+
|
|
166
|
+
You can execute the following command to execute tests;
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
npm run test:integration:mysql8
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
[MIT License](LICENSE)
|