@thzero/library_server 0.14.8 → 0.15.4

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/boot/index.js CHANGED
@@ -1,5 +1,4 @@
1
- // import internalIp from 'internal-ip';
2
- // Until author fixes the issue with version 7+
1
+ import http from 'http';
3
2
  import {internalIpV6, internalIpV4} from '@thzero/library_server/utility/internalIp';
4
3
 
5
4
  import { createTerminus } from '@godaddy/terminus';
@@ -13,7 +12,22 @@ import Utility from '@thzero/library_common/utility';
13
12
 
14
13
  import NotImplementedError from '@thzero/library_common/errors/notImplemented';
15
14
 
16
- require('@thzero/library_common/utility/string');
15
+ // require('@thzero/library_server/utility/string.cjs');
16
+ String.isNullOrEmpty = function(value) {
17
+ //return !(typeof value === 'string' && value.length > 0)
18
+ return !value;
19
+ }
20
+
21
+ String.isString = function(value) {
22
+ return (typeof value === "string" || value instanceof String);
23
+ }
24
+
25
+ String.trim = function(value) {
26
+ if (!value || !String.isString(value))
27
+ return value;
28
+ return value.trim();
29
+ }
30
+
17
31
  import injector from '@thzero/library_common/utility/injector';
18
32
 
19
33
  import usageMetricsRepository from '../repository/usageMetrics/devnull';
@@ -46,7 +60,7 @@ class BootMain {
46
60
  this.loggerServiceI.info2(`process.env.PORT: ${process.env.PORT}`);
47
61
  this.port = process.env.PORT || this.port;
48
62
  this.loggerServiceI.info2(`selected.port: ${this.port}`);
49
- const serverHttp = require('http').createServer(app.callback());
63
+ const serverHttp = http.createServer(app.callback());
50
64
 
51
65
  function onSignal() {
52
66
  this.loggerServiceI.info2(`server is starting cleanup`);
package/boot/koa/index.js CHANGED
@@ -8,7 +8,6 @@ import Utility from '@thzero/library_common/utility';
8
8
 
9
9
  import TokenExpiredError from '../../errors/tokenExpired';
10
10
 
11
- require('@thzero/library_common/utility/string');
12
11
  import injector from '@thzero/library_common/utility/injector';
13
12
 
14
13
  import BootMain from '@thzero/library_server/boot';
@@ -1,14 +1,13 @@
1
1
  import LibraryConstants from '../../constants';
2
2
  import LibraryCommonServiceConstants from '@thzero/library_common_service/constants';
3
3
 
4
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
5
-
6
4
  import BootPlugin from './index';
7
5
 
8
6
  import homeRoute from '../../routes/home';
9
7
  import versionRoute from '../../routes/version';
10
8
 
11
9
  import cryptoService from '../../service/crypto';
10
+ import versionService from '../../service/version';
12
11
 
13
12
  class ApiBootPlugin extends BootPlugin {
14
13
  async _initRoutesPost() {
@@ -52,7 +51,7 @@ class ApiBootPlugin extends BootPlugin {
52
51
  }
53
52
 
54
53
  _initServicesVersion() {
55
- throw new NotImplementedError();
54
+ return new versionService();
56
55
  }
57
56
  }
58
57
 
@@ -3,7 +3,21 @@ import LibraryCommonServiceConstants from '@thzero/library_common_service/consta
3
3
 
4
4
  import injector from '@thzero/library_common/utility/injector';
5
5
 
6
- require('@thzero/library_common/utility/string');
6
+ // require('../utility/string.cjs');
7
+ String.isNullOrEmpty = function(value) {
8
+ //return !(typeof value === 'string' && value.length > 0)
9
+ return !value;
10
+ }
11
+
12
+ String.isString = function(value) {
13
+ return (typeof value === "string" || value instanceof String);
14
+ }
15
+
16
+ String.trim = function(value) {
17
+ if (!value || !String.isString(value))
18
+ return value;
19
+ return value.trim();
20
+ }
7
21
 
8
22
  const logicalAnd = 'and';
9
23
  const logicalOr = 'or';
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@thzero/library_server",
3
- "version": "0.14.8",
3
+ "type": "module",
4
+ "version": "0.15.4",
4
5
  "version_major": 0,
5
- "version_minor": 14,
6
- "version_patch": 8,
7
- "version_date": "10/20/2021",
6
+ "version_minor": 15,
7
+ "version_patch": 4,
8
+ "version_date": "12/13/2021",
8
9
  "description": "An opinionated library of common functionality to bootstrap a Koa based API application using MongoDb and Firebase.",
9
10
  "author": "thZero",
10
11
  "license": "MIT",
@@ -33,7 +34,7 @@
33
34
  "dayjs": "^1.10.7",
34
35
  "dayjs-plugin-utc": "^0.1.2",
35
36
  "default-gateway": "^6.0.3",
36
- "easy-rbac": "^3.1.1",
37
+ "easy-rbac": "^3.2.0",
37
38
  "esm": "^3.2.25",
38
39
  "ipaddr.js": "^2.0.1",
39
40
  "koa": "^2.13.4",
@@ -45,16 +46,16 @@
45
46
  "@thzero/library_cli": "^0.13.21"
46
47
  },
47
48
  "peerDependencies": {
48
- "@thzero/library_common": "^0.14",
49
- "@thzero/library_common_service": "^0.14",
50
- "@babel/core": "^7.15.8",
51
- "@babel/plugin-proposal-class-properties": "^7.14.5",
52
- "@babel/preset-env": "^7.15.8",
53
- "babel-loader": "^8.2.2",
54
- "eslint": "^8.0.1",
49
+ "@thzero/library_common": "^0.15",
50
+ "@thzero/library_common_service": "^0.15",
51
+ "@babel/core": "^7.16.5",
52
+ "@babel/plugin-proposal-class-properties": "^7.16.5",
53
+ "@babel/preset-env": "^7.16.5",
54
+ "babel-loader": "^8.2.3",
55
+ "eslint": "^8.4.1",
55
56
  "eslint-plugin-node": "^11.1.0",
56
- "pino-pretty": "^7.1.0",
57
- "webpack": "^5.59.0",
57
+ "pino-pretty": "^7.3.0",
58
+ "webpack": "^5.65.0",
58
59
  "webpack-cli": "^4.9.1"
59
60
  }
60
61
  }
@@ -1,10 +1,20 @@
1
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
1
+ import fs from 'fs';
2
+ import path from 'path';
2
3
 
3
4
  import Service from './index';
4
5
 
5
6
  class VersionService extends Service {
6
7
  async version(correlationId) {
7
- throw new NotImplementedError();
8
+ const filePath = path.join(process.cwd(), 'package.json');
9
+ const file = fs.readFileSync(filePath, 'utf8');
10
+ if (String.isNullOrEmpty(file))
11
+ throw Error('Invalid package.json file for versioning; expected in the <app root> folder.');
12
+
13
+ const packageObj = JSON.parse(file);
14
+ if (!packageObj)
15
+ throw Error('Invalid package.json file for versioning.');
16
+
17
+ return this._generate(correlationId, packageObj.version_major, packageObj.version_minor, packageObj.version_patch, packageObj.version_date);
8
18
  }
9
19
 
10
20
  _generate(correlationId, version_major, version_minor, version_patch, version_date) {