axe-api 1.0.8 → 1.0.10

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.
@@ -9,8 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ const Helpers_1 = require("../../Handlers/Helpers");
12
13
  exports.default = (context) => __awaiter(void 0, void 0, void 0, function* () {
13
- if (context.query) {
14
+ if (context.query && context.queryParser && context.conditions) {
15
+ // Users should be able to select some fields to show.
16
+ context.queryParser.applyFields(context.query, context.conditions.fields);
17
+ // Binding parent id if there is.
18
+ (0, Helpers_1.addForeignKeyQuery)(context.req, context.query, context.relation, context.parentModel);
19
+ // Users should be able to filter records
20
+ context.queryParser.applyWheres(context.query, context.conditions.q);
21
+ // User should be able to select sorting fields and types
22
+ context.queryParser.applySorting(context.query, context.conditions.sort);
14
23
  context.result = yield context.query;
15
24
  }
16
25
  });
@@ -1,4 +1,4 @@
1
- import connect, { NextHandleFunction, ErrorHandleFunction } from "connect";
1
+ import connect, { HandleFunction, NextHandleFunction, ErrorHandleFunction } from "connect";
2
2
  import { GeneralFunction } from "../Types";
3
3
  declare class App {
4
4
  private connect;
@@ -20,7 +20,9 @@ declare class App {
20
20
  * next()
21
21
  * })
22
22
  */
23
- use(middleware: NextHandleFunction | ErrorHandleFunction): void;
23
+ use(middleware: NextHandleFunction): void;
24
+ use(middleware: HandleFunction): void;
25
+ use(middleware: ErrorHandleFunction): void;
24
26
  /**
25
27
  * Add a GET request handler with middleware support
26
28
  *
@@ -33,15 +33,6 @@ class App {
33
33
  get instance() {
34
34
  return this.connect;
35
35
  }
36
- /**
37
- * Add a global connect middleware
38
- *
39
- * @param middleware
40
- * @example
41
- * app.use((req: IncomingMessage, res: ServerResponse, next: any) => {
42
- * next()
43
- * })
44
- */
45
36
  use(middleware) {
46
37
  this.connect.use(middleware);
47
38
  LogService_1.default.debug(`New middleware: ${middleware.name || "anonymous"}()`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axe-api",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
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",
@@ -107,6 +107,7 @@
107
107
  "pg": "^8.11.3",
108
108
  "prettier": "^3.1.1",
109
109
  "redis": "^4.6.11",
110
+ "serve-static": "^1.15.0",
110
111
  "set-value": ">=4.1.0",
111
112
  "sqlite3": "^5.1.6",
112
113
  "ts-node": "^10.9.2",