@mimik/init 5.0.3 → 5.2.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/README.md +2 -1
- package/index.js +21 -1
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -33,7 +33,8 @@ The `return` object has the following strucuture:
|
|
|
33
33
|
}
|
|
34
34
|
```
|
|
35
35
|
For the preOps, postOps and exitOps the function are executed with 3 parameters (correlationId, config, server).
|
|
36
|
-
The following routes are reserved:
|
|
36
|
+
The following routes are reserved: `/healthcheck` and `/metrics`.
|
|
37
|
+
The base path is defined by taking the url property of the first item of the servers array in the api defintion file. Only relative url address will be handled (e.g. /mss/v1) and not template are allowed.
|
|
37
38
|
|
|
38
39
|
| Param | Type | Description |
|
|
39
40
|
| --- | --- | --- |
|
package/index.js
CHANGED
|
@@ -61,7 +61,8 @@ const {
|
|
|
61
61
|
* }
|
|
62
62
|
* ```
|
|
63
63
|
* For the preOps, postOps and exitOps the function are executed with 3 parameters (correlationId, config, server).
|
|
64
|
-
* The following routes are reserved:
|
|
64
|
+
* The following routes are reserved: `/healthcheck` and `/metrics`.
|
|
65
|
+
* The base path is defined by taking the url property of the first item of the servers array in the api defintion file. Only relative url address will be handled (e.g. /mss/v1) and not template are allowed.
|
|
65
66
|
*/
|
|
66
67
|
module.exports = (app, rootDir, config, validates, cluster, options) => {
|
|
67
68
|
const fatalError = (error, correlationId) => {
|
|
@@ -96,6 +97,7 @@ module.exports = (app, rootDir, config, validates, cluster, options) => {
|
|
|
96
97
|
const buildRequire = pathLib.join(buildDirectory, BUILD_FILENAME);
|
|
97
98
|
const extractName = options ? options.extractName : null;
|
|
98
99
|
const metrics = options ? options.metrics : null;
|
|
100
|
+
const oidcOps = options ? options.oidcOps : null;
|
|
99
101
|
let apiFilename = serverSettings.api;
|
|
100
102
|
let registration = false;
|
|
101
103
|
|
|
@@ -127,12 +129,30 @@ module.exports = (app, rootDir, config, validates, cluster, options) => {
|
|
|
127
129
|
app.get(METRICS_ROUTE, metricsRoute(options));
|
|
128
130
|
app.use(startHrTimeSet(metrics.APIRequestDuration));
|
|
129
131
|
}
|
|
132
|
+
if (oidcOps && typeof oidcOps === 'function') {
|
|
133
|
+
oidcOps();
|
|
134
|
+
}
|
|
130
135
|
if (extractName) { app.use(extractLogs(config, extractName, options)); }
|
|
131
136
|
if (apiFilename[0] !== '/') apiFilename = pathLib.join(rootDir, apiFilename);
|
|
132
137
|
logger.debug('location of the api file', { apiFilename }, correlationIdStart);
|
|
133
138
|
return setupServerFiles(apiFilename, controllersDirectory, buildDirectory, correlationIdStart, updateOptions(options))
|
|
134
139
|
.then((setupResult) => {
|
|
135
140
|
serverSettings.basePath = setupResult.apiDefinition.servers[0].url; // need to address that later
|
|
141
|
+
// this will be deprecated by init 6.0
|
|
142
|
+
app.use((req, res, next) => {
|
|
143
|
+
const parts = req.url.split('/');
|
|
144
|
+
const partsLength = parts.length;
|
|
145
|
+
const baseParts = serverSettings.basePath.split('/');
|
|
146
|
+
|
|
147
|
+
baseParts.every((basePart, index) => {
|
|
148
|
+
if (index > partsLength || basePart.toLowerCase() !== parts[index].toLowerCase()) return false;
|
|
149
|
+
parts[index] = basePart;
|
|
150
|
+
return true;
|
|
151
|
+
});
|
|
152
|
+
req.url = parts.join('/');
|
|
153
|
+
next();
|
|
154
|
+
});
|
|
155
|
+
// end of deprecation
|
|
136
156
|
// eslint-disable-next-line import/no-dynamic-require,global-require
|
|
137
157
|
const registeredOperations = require(buildRequire);
|
|
138
158
|
const api = apiSetup(setupResult, registeredOperations, options?.secOptions, options?.formats, config, correlationIdStart);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/init",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Init process for micro-service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"test": "echo \"Error: no test specified\" && exit 0",
|
|
10
10
|
"test-ci": "echo \"Error: no test specified\" && exit 0",
|
|
11
11
|
"prepublishOnly": "npm run docs && npm run lint && npm run test-ci",
|
|
12
|
-
"commit-ready": "npm run docs && npm run lint && npm run test-ci"
|
|
13
|
-
"prepare": "husky install"
|
|
12
|
+
"commit-ready": "npm run docs && npm run lint && npm run test-ci"
|
|
14
13
|
},
|
|
15
14
|
"husky": {
|
|
16
15
|
"hooks": {
|
|
@@ -48,8 +47,8 @@
|
|
|
48
47
|
"eslint": "8.57.0",
|
|
49
48
|
"eslint-config-airbnb": "19.0.4",
|
|
50
49
|
"eslint-plugin-import": "2.29.1",
|
|
51
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
52
|
-
"eslint-plugin-react": "7.34.
|
|
50
|
+
"eslint-plugin-jsx-a11y": "6.9.0",
|
|
51
|
+
"eslint-plugin-react": "7.34.3",
|
|
53
52
|
"eslint-plugin-react-hooks": "4.6.2",
|
|
54
53
|
"husky": "9.0.11",
|
|
55
54
|
"jsdoc-to-markdown": "8.0.1"
|