axe-api 0.20.0-rc8 → 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.
Files changed (71) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/package.json +66 -64
  3. package/readme.md +174 -152
  4. package/build/index.d.ts +0 -7
  5. package/build/index.js +0 -30
  6. package/build/src/Builders/ModelTreeBuilder.d.ts +0 -9
  7. package/build/src/Builders/ModelTreeBuilder.js +0 -64
  8. package/build/src/Builders/RouterBuilder.d.ts +0 -15
  9. package/build/src/Builders/RouterBuilder.js +0 -219
  10. package/build/src/Builders/index.d.ts +0 -3
  11. package/build/src/Builders/index.js +0 -10
  12. package/build/src/Enums.d.ts +0 -77
  13. package/build/src/Enums.js +0 -90
  14. package/build/src/Exceptions/ApiError.d.ts +0 -8
  15. package/build/src/Exceptions/ApiError.js +0 -12
  16. package/build/src/Handlers/AllHandler.d.ts +0 -4
  17. package/build/src/Handlers/AllHandler.js +0 -44
  18. package/build/src/Handlers/DestroyHandler.d.ts +0 -4
  19. package/build/src/Handlers/DestroyHandler.js +0 -37
  20. package/build/src/Handlers/HandlerFactory.d.ts +0 -6
  21. package/build/src/Handlers/HandlerFactory.js +0 -36
  22. package/build/src/Handlers/Helpers.d.ts +0 -14
  23. package/build/src/Handlers/Helpers.js +0 -231
  24. package/build/src/Handlers/PaginateHandler.d.ts +0 -4
  25. package/build/src/Handlers/PaginateHandler.js +0 -48
  26. package/build/src/Handlers/PatchHandler.d.ts +0 -4
  27. package/build/src/Handlers/PatchHandler.js +0 -62
  28. package/build/src/Handlers/ShowHandler.d.ts +0 -4
  29. package/build/src/Handlers/ShowHandler.js +0 -51
  30. package/build/src/Handlers/StoreHandler.d.ts +0 -4
  31. package/build/src/Handlers/StoreHandler.js +0 -59
  32. package/build/src/Handlers/UpdateHandler.d.ts +0 -4
  33. package/build/src/Handlers/UpdateHandler.js +0 -62
  34. package/build/src/Interfaces.d.ts +0 -165
  35. package/build/src/Interfaces.js +0 -3
  36. package/build/src/Model.d.ts +0 -24
  37. package/build/src/Model.js +0 -108
  38. package/build/src/Resolvers/FileResolver.d.ts +0 -5
  39. package/build/src/Resolvers/FileResolver.js +0 -76
  40. package/build/src/Resolvers/FolderResolver.d.ts +0 -5
  41. package/build/src/Resolvers/FolderResolver.js +0 -19
  42. package/build/src/Resolvers/GeneralHookResolver.d.ts +0 -5
  43. package/build/src/Resolvers/GeneralHookResolver.js +0 -35
  44. package/build/src/Resolvers/ModelMiddlewareResolver.d.ts +0 -7
  45. package/build/src/Resolvers/ModelMiddlewareResolver.js +0 -29
  46. package/build/src/Resolvers/ModelResolver.d.ts +0 -9
  47. package/build/src/Resolvers/ModelResolver.js +0 -101
  48. package/build/src/Resolvers/TransactionResolver.d.ts +0 -8
  49. package/build/src/Resolvers/TransactionResolver.js +0 -75
  50. package/build/src/Resolvers/index.d.ts +0 -7
  51. package/build/src/Resolvers/index.js +0 -18
  52. package/build/src/Server.d.ts +0 -8
  53. package/build/src/Server.js +0 -101
  54. package/build/src/Services/DocumentationService.d.ts +0 -9
  55. package/build/src/Services/DocumentationService.js +0 -22
  56. package/build/src/Services/IoCService.d.ts +0 -9
  57. package/build/src/Services/IoCService.js +0 -51
  58. package/build/src/Services/LogService.d.ts +0 -12
  59. package/build/src/Services/LogService.js +0 -41
  60. package/build/src/Services/ModelListService.d.ts +0 -8
  61. package/build/src/Services/ModelListService.js +0 -18
  62. package/build/src/Services/ModelService.d.ts +0 -20
  63. package/build/src/Services/ModelService.js +0 -38
  64. package/build/src/Services/QueryService.d.ts +0 -39
  65. package/build/src/Services/QueryService.js +0 -447
  66. package/build/src/Services/SchemaValidatorService.d.ts +0 -12
  67. package/build/src/Services/SchemaValidatorService.js +0 -114
  68. package/build/src/Services/index.d.ts +0 -8
  69. package/build/src/Services/index.js +0 -20
  70. package/build/src/constants.d.ts +0 -23
  71. 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,64 +1,66 @@
1
- {
2
- "name": "axe-api",
3
- "version": "0.20.0-rc8",
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": "ISC",
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
- "test:integration:mysql8": "cd ./tests/integrations && node index.js mysql8",
24
- "test:integration:mysql57": "cd ./tests/integrations && node index.js mysql57",
25
- "test:integration:postgres": "cd ./tests/integrations && node index.js postgres"
26
- },
27
- "dependencies": {
28
- "change-case": "^4.1.2",
29
- "dotenv": "^14.2.0",
30
- "express": "^4.17.2",
31
- "http-status-codes": "^2.2.0",
32
- "knex": "^1.0.1",
33
- "knex-paginate": "^3.0.0",
34
- "knex-schema-inspector": "^1.7.1",
35
- "pluralize": "^8.0.0",
36
- "validatorjs": "^3.22.1"
37
- },
38
- "devDependencies": {
39
- "@babel/cli": "^7.16.8",
40
- "@babel/core": "^7.16.10",
41
- "@babel/node": "^7.16.8",
42
- "@babel/preset-env": "^7.16.11",
43
- "@babel/runtime": "^7.16.7",
44
- "@types/pluralize": "^0.0.29",
45
- "babel-jest": "^27.4.6",
46
- "babel-loader": "^8.2.3",
47
- "babel-plugin-module-resolver": "^4.1.0",
48
- "babel-preset-minify": "^0.5.1",
49
- "eslint": "^7.31.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-standard": "^5.0.0",
55
- "eslint-plugin-unicorn": "^33.0.1",
56
- "eslint-watch": "^7.0.0",
57
- "jest": "^27.4.7",
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
- }
64
- }
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/logo.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
- The fastest way to create Rest API, by defining database models and relations.
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 the _fastest_ way to create **Rest API** by defining only database models and relationships between them. It is built on [Knex.js](http://knexjs.org), and its awesome active records pattern. On the other hand, you have another familiar thing, [Express](https://expressjs.com/).
33
-
34
- You are going to be able to develop an API **10 times faster** with **Axe API**!
35
-
36
- ## How It Works?
37
-
38
- [Express](https://expressjs.com/) and [Knex.js](http://knexjs.org) are great tools to create [Node.js](https://nodejs.org) based applications. But usually, we code too much the same things to design an API. We aim to reduce code duplication and give you speed by using Axe API.
39
-
40
- Axe API provides you the ability to separate your common tasks to build an API from your business logic. **Axe API** expects model definitions to analyze your routing structure. After you created your models and their relations between them, Axe API can handle all _well-known_ API requests. Creating an API with 5 tables takes almost 15 minutes.
41
-
42
- Shortly, **Axe API** performs three basic functions;
43
-
44
- - **Analyzes** your models and their relationships to create routes.
45
- - **Handles** all HTTP requests.
46
- - **Separate** your business logic from API best practices.
47
-
48
- Let's assume that you have a model like this;
49
-
50
- ```js
51
- import { Model } from "axe-api";
52
-
53
- class User extends Model {}
54
- ```
55
-
56
- With this model, you will have all of the basic API routes for **User** resources. **Axe API** will create **CRUD** routes for you in the _booting_ process and these routes would be completely ready to be handled and processed by Axe API. The following routes will be handled automatically;
57
-
58
- - `POST api/users`
59
- - `GET api/users`
60
- - `GET api/users/:id`
61
- - `PUT api/users/:id`
62
- - `DELETE api/users/:id`
63
-
64
- This is the magic of **Axe API**!
65
-
66
- ## Installation
67
-
68
- 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).
69
-
70
- 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;
71
-
72
- ```bash
73
- $ npm i -g axe-magic
74
- $ axe-magic --version
75
- 1.0.0
76
- ```
77
-
78
- After that, creating a new project is very easy. Just you can execute the following command;
79
-
80
- ```bash
81
- $ axe-magic new my-api
82
- ```
83
-
84
- 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**.
85
-
86
- To install your project's depencies, you can execute the following commands in the root directory;
87
-
88
- ```bash
89
- $ cd my-api
90
- $ npm install
91
- ```
92
-
93
- To serve this application, you can execute the following command;
94
-
95
- ```bash
96
- $ npm run start:dev
97
- ```
98
-
99
- > `start:dev` command use [nodemon](https://www.npmjs.com/package/nodemon). If you haven't installed it yet, we suggest you install it first.
100
-
101
- After that, your first **Axe API** application will be running in `localhost:3000`.
102
-
103
- You will see the following API response if you visit [localhost:3000](http://localhost:3000).
104
-
105
- ```json
106
- {
107
- "name": "AXE API",
108
- "description": "The best API creation tool in the world.",
109
- "aim": "To kill them all!"
110
- }
111
- ```
112
-
113
- If you can see that response, it means that your project is running properly.
114
-
115
- ## Documentation
116
-
117
- Axe API has great documentation. Please [check it out in here](https://axe-api.github.io/).
118
-
119
- ## How To Run Integration Tests
120
-
121
- > You have to have **Docker** and **Docker Compose** on your local development environment to run integration tests.
122
-
123
- Execute the following commands to prepare the integration app
124
-
125
- ```sh
126
- cd tests/integrations && npm install && npm ci && npm run build --if-present
127
- ```
128
-
129
- Execute the following commands to prepare the database;
130
-
131
- ```sh
132
- docker-compose -f "./tests/integrations/docker-compose.mysql8.yml" up -d --build
133
- ```
134
-
135
- > To down the database, you can use the following command; `docker-compose -f "./tests/integrations/docker-compose.mysql8.yml" up -d --build`
136
-
137
- You can execute the following command to execute tests;
138
-
139
- ```sh
140
- npm run test:integration:mysql8
141
- ```
142
-
143
- ## License
144
-
145
- [MIT License](LICENSE)
146
-
147
- ## Prerelease
148
-
149
- - Update package.json, set version to a prerelease version, e.g. 2.0.0-rc1, 3.1.5-rc4, ...
150
- - Run npm pack to create package
151
- - Run npm publish <package>.tgz --tag next to publish the package under the next tag
152
- - Run npm install --save package@next to install prerelease package
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)
package/build/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import Server from "./src/Server";
2
- import Model from "./src/Model";
3
- import ApiError from "./src/Exceptions/ApiError";
4
- import { DEFAULT_HANDLERS } from "./src/constants";
5
- export * from "./src/Enums";
6
- export * from "./src/Interfaces";
7
- export { Server, Model, ApiError, DEFAULT_HANDLERS };