@eik/service 1.2.95 → 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 CHANGED
@@ -1,3 +1,41 @@
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
+
18
+ ## [1.2.98](https://github.com/eik-lib/service/compare/v1.2.97...v1.2.98) (2021-10-12)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **deps:** update dependency @eik/core to v1.2.25 ([2062d63](https://github.com/eik-lib/service/commit/2062d63f4c9753166f99a8149cf60bdd4b531fec))
24
+
25
+ ## [1.2.97](https://github.com/eik-lib/service/compare/v1.2.96...v1.2.97) (2021-10-11)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **deps:** update dependency fastify-jwt to v3.2.0 ([a63e5c2](https://github.com/eik-lib/service/commit/a63e5c23fddc2b3003ddf8df8ff7c911ef5e7aa5))
31
+
32
+ ## [1.2.96](https://github.com/eik-lib/service/compare/v1.2.95...v1.2.96) (2021-10-08)
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * **deps:** update dependency @eik/core to v1.2.23 ([1f0ef86](https://github.com/eik-lib/service/commit/1f0ef86a9b2520a08d19eab53f74399c402eb2d6))
38
+
1
39
  ## [1.2.95](https://github.com/eik-lib/service/compare/v1.2.94...v1.2.95) (2021-09-30)
2
40
 
3
41
 
package/bin/eik-server.js CHANGED
@@ -1,26 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const fastify = require('fastify');
4
- const Eik = require("..");
3
+ import Fastify from 'fastify'
4
+ import Eik from '../lib/main.js';
5
5
 
6
- const run = async () => {
7
- const eik = new Eik();
6
+ const eik = new Eik();
8
7
 
9
- const app = fastify({
10
- ignoreTrailingSlash: true,
11
- modifyCoreObjects: false,
12
- trustProxy: true,
13
- http2: eik.config.get('http.http2'),
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
- app.register(eik.api());
15
+ app.register(eik.api());
17
16
 
18
- try {
19
- await eik.health();
20
- } catch (error) {
21
- // Do accept errors
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
- run();
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
- 'use strict';
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 convict = require('convict');
4
- const yaml = require('js-yaml');
5
- const path = require('path');
6
- const pino = require('pino');
7
- const fs = require('fs');
8
- const os = require('os');
9
- const pack = require('../package.json');
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
- const dir = process.cwd();
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
- module.exports = conf;
170
+ export default conf;
package/lib/main.js CHANGED
@@ -1,15 +1,14 @@
1
- 'use strict;'
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
- const config = require('./config');
12
- const utils = require('./utils');
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
- module.exports = EikService;
573
+
574
+ export default EikService;
package/lib/utils.js CHANGED
@@ -1,6 +1,4 @@
1
- 'use strict';
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
- module.exports.sanitizeParameters = sanitizeParameters;
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": "1.2.95",
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 ."
@@ -32,33 +33,34 @@
32
33
  },
33
34
  "homepage": "https://github.com/eik-lib/service#readme",
34
35
  "dependencies": {
35
- "@eik/core": "1.2.22",
36
+ "@eik/core": "1.2.25",
36
37
  "convict": "6.2.0",
37
38
  "fastify": "3.22.0",
38
39
  "fastify-compress": "3.6.0",
39
40
  "fastify-cors": "6.0.2",
40
- "fastify-jwt": "3.1.0",
41
+ "fastify-jwt": "3.2.0",
41
42
  "http-errors": "1.8.0",
42
43
  "js-yaml": "4.1.0",
43
44
  "pino": "6.13.3"
44
45
  },
45
46
  "devDependencies": {
46
- "@semantic-release/changelog": "5.0.1",
47
- "@semantic-release/commit-analyzer": "8.0.1",
48
- "@semantic-release/git": "9.0.1",
49
- "@semantic-release/github": "7.2.3",
50
- "@semantic-release/npm": "7.1.3",
51
- "@semantic-release/release-notes-generator": "9.0.3",
47
+ "@babel/eslint-parser": "7.15.8",
48
+ "@semantic-release/changelog": "6.0.0",
49
+ "@semantic-release/commit-analyzer": "9.0.1",
50
+ "@semantic-release/git": "10.0.0",
51
+ "@semantic-release/github": "8.0.1",
52
+ "@semantic-release/npm": "8.0.0",
53
+ "@semantic-release/release-notes-generator": "10.0.2",
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.24.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": "2.6.5",
60
+ "node-fetch": "3.0.0",
59
61
  "pino-pretty": "7.0.1",
60
62
  "prettier": "2.4.1",
61
- "semantic-release": "17.4.7",
63
+ "semantic-release": "18.0.0",
62
64
  "tap": "15.0.10",
63
65
  "unique-slug": "2.0.2"
64
66
  }