@eik/service 1.2.98 → 2.0.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/CHANGELOG.md +17 -0
- package/bin/eik-server.js +16 -19
- package/lib/config.js +17 -11
- package/lib/main.js +11 -11
- package/lib/utils.js +8 -7
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
# [2.0.0](https://github.com/eik-lib/service/compare/v1.2.98...v2.0.0) (2021-10-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Re-name Semantic Release config file to common JS ([4ee1390](https://github.com/eik-lib/service/commit/4ee1390311ac8ea7f68ec9a46e4844b88bc357c5))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### chore
|
|
10
|
+
|
|
11
|
+
* Convert to ESM ([cadf6dc](https://github.com/eik-lib/service/commit/cadf6dcaf1af7e747c398db9063f170eed4a9515))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* The modules is now ESM and will not we compatible with use in a Common JS project.
|
|
17
|
+
|
|
1
18
|
## [1.2.98](https://github.com/eik-lib/service/compare/v1.2.97...v1.2.98) (2021-10-12)
|
|
2
19
|
|
|
3
20
|
|
package/bin/eik-server.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import Fastify from 'fastify'
|
|
4
|
+
import Eik from '../lib/main.js';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const eik = new Eik();
|
|
6
|
+
const eik = new Eik();
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const app = Fastify({
|
|
9
|
+
ignoreTrailingSlash: true,
|
|
10
|
+
modifyCoreObjects: false,
|
|
11
|
+
trustProxy: true,
|
|
12
|
+
http2: eik.config.get('http.http2'),
|
|
13
|
+
});
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
app.register(eik.api());
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
await app.listen(eik.config.get('http.port'), eik.config.get('http.address'));
|
|
17
|
+
try {
|
|
18
|
+
await eik.health();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
// Do accept errors
|
|
25
21
|
}
|
|
26
|
-
|
|
22
|
+
|
|
23
|
+
await app.listen(eik.config.get('http.port'), eik.config.get('http.address'));
|
package/lib/config.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import convict from 'convict';
|
|
2
|
+
import yaml from 'js-yaml';
|
|
3
|
+
import pino from 'pino';
|
|
4
|
+
import path, { dirname, join } from 'path';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import os from 'os';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
2
8
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
let pack = {};
|
|
12
|
+
try {
|
|
13
|
+
pack = JSON.parse(fs.readFileSync(join(__dirname, '../../package.json')));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
/* empty */
|
|
16
|
+
}
|
|
10
17
|
|
|
11
18
|
convict.addParser({ extension: ['yml', 'yaml'], parse: yaml.load });
|
|
12
19
|
|
|
@@ -153,12 +160,11 @@ const logger = pino({
|
|
|
153
160
|
});
|
|
154
161
|
|
|
155
162
|
try {
|
|
156
|
-
|
|
157
|
-
conf.loadFile(path.join(dir, `/config/${env}.yaml`));
|
|
163
|
+
conf.loadFile(path.join(__dirname, `../config/${env}.yaml`));
|
|
158
164
|
} catch (error) {
|
|
159
165
|
logger.error(error);
|
|
160
166
|
}
|
|
161
167
|
|
|
162
168
|
conf.validate();
|
|
163
169
|
|
|
164
|
-
|
|
170
|
+
export default conf;
|
package/lib/main.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
'
|
|
1
|
+
import { PassThrough } from 'stream';
|
|
2
|
+
import compression from 'fastify-compress';
|
|
3
|
+
import HttpError from 'http-errors';
|
|
4
|
+
import pino from 'pino';
|
|
5
|
+
import cors from 'fastify-cors';
|
|
6
|
+
import jwt from 'fastify-jwt';
|
|
7
|
+
import eik from '@eik/core';
|
|
2
8
|
|
|
3
|
-
const { PassThrough } = require('stream');
|
|
4
|
-
const compression = require('fastify-compress');
|
|
5
|
-
const HttpError = require('http-errors');
|
|
6
|
-
const pino = require('pino');
|
|
7
|
-
const cors = require('fastify-cors');
|
|
8
|
-
const jwt = require('fastify-jwt');
|
|
9
|
-
const eik = require('@eik/core');
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import config from './config.js';
|
|
11
|
+
import * as utils from './utils.js';
|
|
13
12
|
|
|
14
13
|
const EikService = class EikService {
|
|
15
14
|
constructor({
|
|
@@ -571,4 +570,5 @@ const EikService = class EikService {
|
|
|
571
570
|
}
|
|
572
571
|
}
|
|
573
572
|
};
|
|
574
|
-
|
|
573
|
+
|
|
574
|
+
export default EikService;
|
package/lib/utils.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
1
|
+
import path from 'path';
|
|
4
2
|
|
|
5
3
|
const sanitizeExtras = (extras, version) => {
|
|
6
4
|
if (version && extras) {
|
|
@@ -8,7 +6,6 @@ const sanitizeExtras = (extras, version) => {
|
|
|
8
6
|
}
|
|
9
7
|
return extras || '';
|
|
10
8
|
};
|
|
11
|
-
module.exports.sanitizeExtras = sanitizeExtras;
|
|
12
9
|
|
|
13
10
|
const sanitizeName = (scope, name) => {
|
|
14
11
|
if (scope && name) {
|
|
@@ -16,7 +13,6 @@ const sanitizeName = (scope, name) => {
|
|
|
16
13
|
}
|
|
17
14
|
return scope || '';
|
|
18
15
|
};
|
|
19
|
-
module.exports.sanitizeName = sanitizeName;
|
|
20
16
|
|
|
21
17
|
const sanitizeAlias = (alias = '') => {
|
|
22
18
|
if (alias.startsWith('v')) {
|
|
@@ -24,7 +20,6 @@ const sanitizeAlias = (alias = '') => {
|
|
|
24
20
|
}
|
|
25
21
|
return alias;
|
|
26
22
|
};
|
|
27
|
-
module.exports.sanitizeAlias = sanitizeAlias;
|
|
28
23
|
|
|
29
24
|
const sanitizeParameters = (url = '') => {
|
|
30
25
|
const { pathname } = new URL(url, 'http://localhost/');
|
|
@@ -48,4 +43,10 @@ const sanitizeParameters = (url = '') => {
|
|
|
48
43
|
type: paths[1] || '',
|
|
49
44
|
};
|
|
50
45
|
};
|
|
51
|
-
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
sanitizeParameters,
|
|
49
|
+
sanitizeExtras,
|
|
50
|
+
sanitizeAlias,
|
|
51
|
+
sanitizeName,
|
|
52
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eik/service",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Eik REST API as a standalone HTTP service",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "./lib/main.js",
|
|
6
7
|
"bin": {
|
|
7
8
|
"eik-server": "bin/eik-server.js",
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
},
|
|
11
12
|
"scripts": {
|
|
12
13
|
"start": "node ./bin/eik-server.js | pino-pretty",
|
|
13
|
-
"test": "LOG_LEVEL=fatal tap --no-check-coverage",
|
|
14
|
+
"test": "LOG_LEVEL=fatal tap ./test --no-check-coverage",
|
|
14
15
|
"test:snapshots:update": "LOG_LEVEL=fatal tap --snapshot",
|
|
15
16
|
"lint:fix": "eslint --fix .",
|
|
16
17
|
"lint": "eslint ."
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"pino": "6.13.3"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
47
|
+
"@babel/eslint-parser": "7.15.8",
|
|
46
48
|
"@semantic-release/changelog": "6.0.0",
|
|
47
49
|
"@semantic-release/commit-analyzer": "9.0.1",
|
|
48
50
|
"@semantic-release/git": "10.0.0",
|
|
@@ -52,10 +54,10 @@
|
|
|
52
54
|
"eslint": "7.32.0",
|
|
53
55
|
"eslint-config-airbnb-base": "14.2.1",
|
|
54
56
|
"eslint-config-prettier": "8.3.0",
|
|
55
|
-
"eslint-plugin-import": "2.
|
|
57
|
+
"eslint-plugin-import": "2.25.1",
|
|
56
58
|
"eslint-plugin-prettier": "4.0.0",
|
|
57
59
|
"form-data": "4.0.0",
|
|
58
|
-
"node-fetch": "
|
|
60
|
+
"node-fetch": "3.0.0",
|
|
59
61
|
"pino-pretty": "7.0.1",
|
|
60
62
|
"prettier": "2.4.1",
|
|
61
63
|
"semantic-release": "18.0.0",
|