apeframework 0.0.0-dev.8 → 0.0.0-dev.9

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/README.md CHANGED
@@ -9,5 +9,5 @@ GitHub repository: [ApeFramework/apeframework](https://github.com/ApeFramework/a
9
9
  ## Installation
10
10
 
11
11
  ```
12
- npm install apeframework
12
+ yarn add apeframework
13
13
  ```
package/api/Api.d.ts CHANGED
@@ -10,10 +10,6 @@ declare class Api {
10
10
  host: string;
11
11
  port?: number;
12
12
  endpoints: Endpoint[];
13
- onRequest?: Handler;
14
- onResponse?: Handler;
15
- onNotFound?: Handler;
16
- onError?: ErrorHandler;
17
13
  openapi?: {
18
14
  name?: string;
19
15
  version?: string;
@@ -23,6 +19,10 @@ declare class Api {
23
19
  origin?: string[];
24
20
  };
25
21
  responseValidation?: boolean;
22
+ onRequest?: Handler;
23
+ onResponse?: Handler;
24
+ onNotFound?: Handler;
25
+ onError?: ErrorHandler;
26
26
  });
27
27
  start(): Promise<string>;
28
28
  openapi(): OpenAPIV3.Document;
package/api/Api.js CHANGED
@@ -30,6 +30,7 @@ class Api {
30
30
  }
31
31
  this.server.register(swagger_1.default, {
32
32
  openapi: {
33
+ openapi: '3.1.0',
33
34
  info: {
34
35
  title: params.openapi?.name ?? '',
35
36
  version: params.openapi?.version ?? '',
@@ -44,21 +45,24 @@ class Api {
44
45
  if (params.responseValidation) {
45
46
  this.server.register(response_validation_1.default);
46
47
  }
47
- params.endpoints.forEach((e) => {
48
- this.server.route({
49
- url: e.path,
50
- method: e.method,
51
- schema: {
52
- summary: e.name ?? e.path,
53
- description: e.description,
54
- ...e.schema.params ? { params: e.schema.params } : {},
55
- ...e.schema.query ? { query: e.schema.query } : {},
56
- ...e.schema.headers ? { headers: e.schema.headers } : {},
57
- ...e.schema.body ? { body: e.schema.body } : {},
58
- ...e.schema.response ? { response: e.schema.response } : {},
59
- },
60
- handler: e.handler,
48
+ this.server.register((server, options, done) => {
49
+ params.endpoints.forEach((e) => {
50
+ server.route({
51
+ url: e.path,
52
+ method: e.method,
53
+ schema: {
54
+ summary: e.name ?? e.path,
55
+ description: e.description,
56
+ ...e.schema.params ? { params: e.schema.params } : {},
57
+ ...e.schema.query ? { query: e.schema.query } : {},
58
+ ...e.schema.headers ? { headers: e.schema.headers } : {},
59
+ ...e.schema.body ? { body: e.schema.body } : {},
60
+ ...e.schema.response ? { response: e.schema.response } : {},
61
+ },
62
+ handler: e.handler,
63
+ });
61
64
  });
65
+ done();
62
66
  });
63
67
  }
64
68
  async start() {
package/api/Api.ts CHANGED
@@ -19,10 +19,6 @@ class Api {
19
19
  host: string,
20
20
  port?: number,
21
21
  endpoints: Endpoint[],
22
- onRequest?: Handler,
23
- onResponse?: Handler,
24
- onNotFound?: Handler,
25
- onError?: ErrorHandler,
26
22
  openapi?: {
27
23
  name?: string,
28
24
  version?: string,
@@ -32,6 +28,10 @@ class Api {
32
28
  origin?: string[],
33
29
  },
34
30
  responseValidation?: boolean,
31
+ onRequest?: Handler,
32
+ onResponse?: Handler,
33
+ onNotFound?: Handler,
34
+ onError?: ErrorHandler,
35
35
  }) {
36
36
  this.host = params.host
37
37
  this.port = params.port
@@ -56,6 +56,7 @@ class Api {
56
56
 
57
57
  this.server.register(swagger, {
58
58
  openapi: {
59
+ openapi: '3.1.0',
59
60
  info: {
60
61
  title: params.openapi?.name ?? '',
61
62
  version: params.openapi?.version ?? '',
@@ -73,21 +74,24 @@ class Api {
73
74
  this.server.register(responseValidation)
74
75
  }
75
76
 
76
- params.endpoints.forEach((e) => {
77
- this.server.route({
78
- url: e.path,
79
- method: e.method,
80
- schema: {
81
- summary: e.name ?? e.path,
82
- description: e.description,
83
- ...e.schema.params ? { params: e.schema.params } : {},
84
- ...e.schema.query ? { query: e.schema.query } : {},
85
- ...e.schema.headers ? { headers: e.schema.headers } : {},
86
- ...e.schema.body ? { body: e.schema.body } : {},
87
- ...e.schema.response ? { response: e.schema.response } : {},
88
- },
89
- handler: e.handler,
77
+ this.server.register((server, options, done) => {
78
+ params.endpoints.forEach((e) => {
79
+ server.route({
80
+ url: e.path,
81
+ method: e.method,
82
+ schema: {
83
+ summary: e.name ?? e.path,
84
+ description: e.description,
85
+ ...e.schema.params ? { params: e.schema.params } : {},
86
+ ...e.schema.query ? { query: e.schema.query } : {},
87
+ ...e.schema.headers ? { headers: e.schema.headers } : {},
88
+ ...e.schema.body ? { body: e.schema.body } : {},
89
+ ...e.schema.response ? { response: e.schema.response } : {},
90
+ },
91
+ handler: e.handler,
92
+ })
90
93
  })
94
+ done()
91
95
  })
92
96
  }
93
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apeframework",
3
- "version": "0.0.0-dev.8",
3
+ "version": "0.0.0-dev.9",
4
4
  "license": "MIT",
5
5
  "author": "Matthieu Symoens",
6
6
  "description": "Node.js app framework",