@mimik/api-helper 2.0.0 → 2.0.2
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 +7 -7
- package/index.js +3 -3
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -13,10 +13,10 @@ import { apiSetup, securityLib, getAPIFile, validateSecuritySchemes, extractProp
|
|
|
13
13
|
* [~securityLib(config)](#module_api-helper..securityLib)
|
|
14
14
|
* [~apiSetup(setup, registeredOperations, securityHandlers, extraFormats, config, correlationId)](#module_api-helper..apiSetup) ⇒ <code>Promise</code>
|
|
15
15
|
* [~getAPIFile(apiFilename, correlationId, options)](#module_api-helper..getAPIFile) ⇒ <code>Promise</code>
|
|
16
|
-
* [~setupServerFiles(apiFilename, controllersDirectory,
|
|
16
|
+
* [~setupServerFiles(apiFilename, controllersDirectory, buildDirectory, correlationId, options)](#module_api-helper..setupServerFiles) ⇒ <code>Promise</code>
|
|
17
17
|
* _sync_
|
|
18
18
|
* [~validateSecuritySchemes(apiDefinition, correlationId)](#module_api-helper..validateSecuritySchemes) ⇒
|
|
19
|
-
* [~extractProperties(apiDefinition, controllersDirectory,
|
|
19
|
+
* [~extractProperties(apiDefinition, controllersDirectory, buildDirectory, correlationId)](#module_api-helper..extractProperties) ⇒
|
|
20
20
|
|
|
21
21
|
<a name="module_api-helper..securityLib"></a>
|
|
22
22
|
|
|
@@ -29,7 +29,7 @@ Implement the security flows for the API.
|
|
|
29
29
|
|
|
30
30
|
- <code>Promise</code> An error is thrown if the initiatilization failed.
|
|
31
31
|
|
|
32
|
-
This function is used to setup the
|
|
32
|
+
This function is used to setup the following security handlers for the API:
|
|
33
33
|
- `SystemSecurity` - used for the system operations, like /system, /onbehalf
|
|
34
34
|
- `AdminSecurity` - used for the admin operations, like /admin,
|
|
35
35
|
- `UserSecurity` - used for the user operations, like /user,
|
|
@@ -111,7 +111,7 @@ Gets the API file from swaggerhub and store it in the give PATH location.
|
|
|
111
111
|
|
|
112
112
|
<a name="module_api-helper..setupServerFiles"></a>
|
|
113
113
|
|
|
114
|
-
### api-helper~setupServerFiles(apiFilename, controllersDirectory,
|
|
114
|
+
### api-helper~setupServerFiles(apiFilename, controllersDirectory, buildDirectory, correlationId, options) ⇒ <code>Promise</code>
|
|
115
115
|
Setup and validates files for the server
|
|
116
116
|
|
|
117
117
|
**Kind**: inner method of [<code>api-helper</code>](#module_api-helper)
|
|
@@ -128,7 +128,7 @@ Setup and validates files for the server
|
|
|
128
128
|
| --- | --- | --- |
|
|
129
129
|
| apiFilename | <code>PATH.<string></code> | Name of the file where the API file will be stored. |
|
|
130
130
|
| controllersDirectory | <code>PATH.<string></code> | Directory to find the controller files. |
|
|
131
|
-
|
|
|
131
|
+
| buildDirectory | <code>PATH.<string></code> | Directory where the register file will be stored. |
|
|
132
132
|
| correlationId | <code>UUID.<string></code> | CorrelationId when logging activites. |
|
|
133
133
|
| options | <code>object</code> | Options associated with the call. Use to pass `metrics` to `rpRetry` and `apiKey`` to access private API. |
|
|
134
134
|
|
|
@@ -153,7 +153,7 @@ Validates the known SecuritySchemes: `SystemSecurity`, `AdminSecurity`, `UserSec
|
|
|
153
153
|
|
|
154
154
|
<a name="module_api-helper..extractProperties"></a>
|
|
155
155
|
|
|
156
|
-
### api-helper~extractProperties(apiDefinition, controllersDirectory,
|
|
156
|
+
### api-helper~extractProperties(apiDefinition, controllersDirectory, buildDirectory, correlationId) ⇒
|
|
157
157
|
Extracts the properties from API definiton and creates a file binding the handler with the controller operations.
|
|
158
158
|
|
|
159
159
|
**Kind**: inner method of [<code>api-helper</code>](#module_api-helper)
|
|
@@ -169,6 +169,6 @@ Extracts the properties from API definiton and creates a file binding the handle
|
|
|
169
169
|
| --- | --- | --- |
|
|
170
170
|
| apiDefinition | <code>object</code> | JSON object containing the API definition. |
|
|
171
171
|
| controllersDirectory | <code>PATH.<string></code> | Directory to find the controller files. |
|
|
172
|
-
|
|
|
172
|
+
| buildDirectory | <code>PATH.<string></code> | Directory where the register file will be stored. |
|
|
173
173
|
| correlationId | <code>UUID.<string></code> | CorrelationId when logging activites. |
|
|
174
174
|
|
package/index.js
CHANGED
|
@@ -67,7 +67,7 @@ const POSTFIX_INDEX = 3;
|
|
|
67
67
|
* &fulfil {object} The API file itself.
|
|
68
68
|
* @throws {Promise} An error is thrown if the initiatilization failed.
|
|
69
69
|
*
|
|
70
|
-
* This function is used to setup the
|
|
70
|
+
* This function is used to setup the following security handlers for the API:
|
|
71
71
|
* - `SystemSecurity` - used for the system operations, like /system, /onbehalf
|
|
72
72
|
* - `AdminSecurity` - used for the admin operations, like /admin,
|
|
73
73
|
* - `UserSecurity` - used for the user operations, like /user,
|
|
@@ -406,7 +406,7 @@ export const validateSecuritySchemes = (apiDefinition, correlationId) => {
|
|
|
406
406
|
* @requires fs
|
|
407
407
|
* @param {object} apiDefinition - JSON object containing the API definition.
|
|
408
408
|
* @param {PATH.<string>} controllersDirectory - Directory to find the controller files.
|
|
409
|
-
* @param {PATH.<string>}
|
|
409
|
+
* @param {PATH.<string>} buildDirectory - Directory where the register file will be stored.
|
|
410
410
|
* @param {UUID.<string>} correlationId - CorrelationId when logging activites.
|
|
411
411
|
* @return null
|
|
412
412
|
* @throws An error is thrown for many reasons, like operationId does not exist in controllers, controller dies not exist...
|
|
@@ -492,7 +492,7 @@ export const extractProperties = (apiDefinition, controllersDirectory, buildDire
|
|
|
492
492
|
* @requires path
|
|
493
493
|
* @param {PATH.<string>} apiFilename - Name of the file where the API file will be stored.
|
|
494
494
|
* @param {PATH.<string>} controllersDirectory - Directory to find the controller files.
|
|
495
|
-
* @param {PATH.<string>}
|
|
495
|
+
* @param {PATH.<string>} buildDirectory - Directory where the register file will be stored.
|
|
496
496
|
* @param {UUID.<string>} correlationId - CorrelationId when logging activites.
|
|
497
497
|
* @param {object} options - Options associated with the call. Use to pass `metrics` to `rpRetry` and `apiKey`` to access private API.
|
|
498
498
|
* @return {Promise}.
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/api-helper",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "helper for openAPI backend and mimik service",
|
|
5
5
|
"main": "./index.js",
|
|
6
|
-
"type": "module",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
7
8
|
"lint": "eslint . --no-error-on-unmatched-pattern",
|
|
8
9
|
"docs": "jsdoc2md index.js > README.md",
|
|
9
10
|
"test": "echo \"Error: no test specified\" && exit 0",
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@eslint/js": "9.31.0",
|
|
49
50
|
"@mimik/eslint-plugin-document-env": "^2.0.8",
|
|
50
|
-
"@stylistic/eslint-plugin": "5.2.
|
|
51
|
+
"@stylistic/eslint-plugin": "5.2.2",
|
|
51
52
|
"eslint": "9.31.0",
|
|
52
53
|
"eslint-plugin-import": "2.32.0",
|
|
53
54
|
"husky": "9.1.7",
|