@brightchain/brightchain-api-lib 0.15.0 → 0.16.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/package.json +4 -4
- package/src/browser.d.ts +13 -0
- package/src/browser.d.ts.map +1 -0
- package/src/browser.js +16 -0
- package/src/browser.js.map +1 -0
- package/src/index.d.ts +1 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/lib/application-base.d.ts +8 -37
- package/src/lib/application-base.d.ts.map +1 -1
- package/src/lib/application-base.js +8 -80
- package/src/lib/application-base.js.map +1 -1
- package/src/lib/application.d.ts +36 -7
- package/src/lib/application.d.ts.map +1 -1
- package/src/lib/application.js +124 -135
- package/src/lib/application.js.map +1 -1
- package/src/lib/constants.js +2 -2
- package/src/lib/constants.js.map +1 -1
- package/src/lib/controllers/api/blocks.d.ts.map +1 -1
- package/src/lib/controllers/api/blocks.js +290 -290
- package/src/lib/controllers/api/blocks.js.map +1 -1
- package/src/lib/controllers/api/brightpass.d.ts.map +1 -1
- package/src/lib/controllers/api/brightpass.js +274 -274
- package/src/lib/controllers/api/brightpass.js.map +1 -1
- package/src/lib/controllers/api/energy.d.ts.map +1 -1
- package/src/lib/controllers/api/energy.js +93 -93
- package/src/lib/controllers/api/energy.js.map +1 -1
- package/src/lib/controllers/api/i18n.d.ts.map +1 -1
- package/src/lib/controllers/api/i18n.js +8 -8
- package/src/lib/controllers/api/i18n.js.map +1 -1
- package/src/lib/controllers/api/quorum.d.ts.map +1 -1
- package/src/lib/controllers/api/quorum.js +483 -483
- package/src/lib/controllers/api/quorum.js.map +1 -1
- package/src/lib/controllers/api/sessions.d.ts.map +1 -1
- package/src/lib/controllers/api/sessions.js +8 -8
- package/src/lib/controllers/api/sessions.js.map +1 -1
- package/src/lib/controllers/api/user.d.ts.map +1 -1
- package/src/lib/controllers/api/user.js +180 -180
- package/src/lib/controllers/api/user.js.map +1 -1
- package/src/lib/interfaces/application.d.ts +7 -1
- package/src/lib/interfaces/application.d.ts.map +1 -1
- package/src/lib/interfaces/brightchain-init-result.d.ts +17 -0
- package/src/lib/interfaces/brightchain-init-result.d.ts.map +1 -0
- package/src/lib/interfaces/brightchain-init-result.js +9 -0
- package/src/lib/interfaces/brightchain-init-result.js.map +1 -0
- package/src/lib/interfaces/index.d.ts +1 -0
- package/src/lib/interfaces/index.d.ts.map +1 -1
- package/src/lib/routers/app.d.ts +22 -14
- package/src/lib/routers/app.d.ts.map +1 -1
- package/src/lib/routers/app.js +28 -116
- package/src/lib/routers/app.js.map +1 -1
- package/src/lib/services/brightpass.property.helpers.d.ts +23 -0
- package/src/lib/services/brightpass.property.helpers.d.ts.map +1 -0
- package/src/lib/services/brightpass.property.helpers.js +113 -0
- package/src/lib/services/brightpass.property.helpers.js.map +1 -0
- package/src/lib/upstream-stubs.d.ts +36 -0
- package/src/lib/upstream-stubs.d.ts.map +1 -0
- package/src/lib/upstream-stubs.js +43 -0
- package/src/lib/upstream-stubs.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightchain/brightchain-api-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"types": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@aws-sdk/client-ses": "^3.859.0",
|
|
8
|
-
"@brightchain/brightchain-lib": "0.
|
|
8
|
+
"@brightchain/brightchain-lib": "0.16.0",
|
|
9
9
|
"@digitaldefiance/branded-enum": "^0.0.7",
|
|
10
10
|
"@digitaldefiance/enclave-bridge-client": "^1.1.0",
|
|
11
|
-
"@digitaldefiance/i18n-lib": "^4.
|
|
12
|
-
"@digitaldefiance/node-ecies-lib": "^4.
|
|
11
|
+
"@digitaldefiance/i18n-lib": "^4.6.2",
|
|
12
|
+
"@digitaldefiance/node-ecies-lib": "^4.19.3",
|
|
13
13
|
"@ethereumjs/wallet": "^10.0.0",
|
|
14
14
|
"bip39": "^3.1.0",
|
|
15
15
|
"buffer": "^6.0.3",
|
package/src/browser.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe exports from brightchain-api-lib
|
|
3
|
+
*
|
|
4
|
+
* This file exports only the types and constants that are safe to use
|
|
5
|
+
* in browser environments, excluding Node.js-specific implementations.
|
|
6
|
+
*/
|
|
7
|
+
export * from './lib/constants';
|
|
8
|
+
export * from './lib/enumerations';
|
|
9
|
+
export * from './lib/errors';
|
|
10
|
+
export type { IApiConstants } from './lib/interfaces/api-constants';
|
|
11
|
+
export type { ClientSession, DefaultBackendIdType, SchemaMap } from './lib/shared-types';
|
|
12
|
+
export * from './lib/browserKeyring';
|
|
13
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../brightchain-api-lib/src/browser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAG7B,YAAY,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGzF,cAAc,sBAAsB,CAAC"}
|
package/src/browser.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Browser-safe exports from brightchain-api-lib
|
|
4
|
+
*
|
|
5
|
+
* This file exports only the types and constants that are safe to use
|
|
6
|
+
* in browser environments, excluding Node.js-specific implementations.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
// Export only constants and types, no Node.js implementations
|
|
11
|
+
tslib_1.__exportStar(require("./lib/constants"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./lib/enumerations"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./lib/errors"), exports);
|
|
14
|
+
// Export browser-safe keyring
|
|
15
|
+
tslib_1.__exportStar(require("./lib/browserKeyring"), exports);
|
|
16
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../brightchain-api-lib/src/browser.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,8DAA8D;AAC9D,0DAAgC;AAChC,6DAAmC;AACnC,uDAA6B;AAM7B,8BAA8B;AAC9B,+DAAqC"}
|
package/src/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './lib/transforms';
|
|
|
3
3
|
export * from './lib/services';
|
|
4
4
|
export * from './lib/appConstants';
|
|
5
5
|
export * from './lib/application';
|
|
6
|
-
export * from './lib/
|
|
6
|
+
export * from './lib/upstream-stubs';
|
|
7
7
|
export * from './lib/constants';
|
|
8
8
|
export * from './lib/controllers';
|
|
9
9
|
export * from './lib/enumerations';
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../brightchain-api-lib/src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../brightchain-api-lib/src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAElC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AAKjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAG9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAE5C,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC"}
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ tslib_1.__exportStar(require("./lib/services"), exports);
|
|
|
9
9
|
// API lib exports
|
|
10
10
|
tslib_1.__exportStar(require("./lib/appConstants"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./lib/application"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./lib/
|
|
12
|
+
tslib_1.__exportStar(require("./lib/upstream-stubs"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./lib/constants"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./lib/controllers"), exports);
|
|
15
15
|
// Note: UserController is exported from controllers/api, not controllers/user (which is the legacy location)
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../brightchain-api-lib/src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,uDAA6B;AAC7B,2DAAiC;AAEjC,mCAAmC;AACnC,yDAA+B;AAE/B,kBAAkB;AAClB,6DAAmC;AACnC,4DAAkC;AAClC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../brightchain-api-lib/src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,uDAA6B;AAC7B,2DAAiC;AAEjC,mCAAmC;AACnC,yDAA+B;AAE/B,kBAAkB;AAClB,6DAAmC;AACnC,4DAAkC;AAClC,+DAAqC;AACrC,0DAAgC;AAChC,4DAAkC;AAClC,6GAA6G;AAC7G,6DAAmC;AACnC,4DAAkC;AAClC,uDAA6B;AAC7B,2DAAiC;AACjC,iGAAiG;AACjG,+EAA+E;AAC/E,gFAAgF;AAEhF,0DAAgC;AAChC,4DAAkC;AAClC,wDAA8B;AAC9B,oGAAoG;AACpG,kFAAkF;AAClF,6DAAmC;AACnC,2DAAiC;AACjC,oEAA0C;AAC1C,sEAA4C;AAQ5C,eAAe;AACf,qDAA2B;AAE3B,qBAAqB;AACrB,2DAAiC;AAEjC,kBAAkB;AAClB,+DAAqC;AACrC,4DAAkC;AAClC,qEAA2C;AAC3C,8DAAoC"}
|
|
@@ -1,40 +1,11 @@
|
|
|
1
|
-
import { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
2
|
-
import { IApplication, IBaseDocument, IConstants, PluginManager, ServiceContainer } from '@digitaldefiance/node-express-suite';
|
|
3
|
-
import { DocumentStore } from './datastore/document-store';
|
|
4
|
-
import { Environment } from './environment';
|
|
5
|
-
import type { DefaultBackendIdType } from './shared-types';
|
|
6
1
|
/**
|
|
7
|
-
*
|
|
2
|
+
* @deprecated This file is no longer used.
|
|
3
|
+
*
|
|
4
|
+
* The local BaseApplication class has been removed as part of the upstream
|
|
5
|
+
* Application refactor. BrightChain's App<TID> now extends the upstream
|
|
6
|
+
* Application from @digitaldefiance/node-express-suite directly, and
|
|
7
|
+
* manages DocumentStore/BlockDocumentStore internally.
|
|
8
|
+
*
|
|
9
|
+
* See: brightchain-api-lib/src/lib/application.ts
|
|
8
10
|
*/
|
|
9
|
-
export declare class BaseApplication<TID extends PlatformID = DefaultBackendIdType> implements IApplication<TID> {
|
|
10
|
-
private _environment;
|
|
11
|
-
get environment(): Environment<TID>;
|
|
12
|
-
get constants(): IConstants;
|
|
13
|
-
get db(): any;
|
|
14
|
-
private _services;
|
|
15
|
-
get services(): ServiceContainer;
|
|
16
|
-
private _plugins;
|
|
17
|
-
get plugins(): PluginManager<TID>;
|
|
18
|
-
getModel<U extends IBaseDocument<any, any>>(modelName: string): U;
|
|
19
|
-
reloadEnvironment(path?: string, override?: boolean): void;
|
|
20
|
-
static get distDir(): string;
|
|
21
|
-
/**
|
|
22
|
-
* Flag indicating whether the application is ready to handle requests
|
|
23
|
-
*/
|
|
24
|
-
protected _ready: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Get whether the application is ready to handle requests
|
|
27
|
-
*/
|
|
28
|
-
get ready(): boolean;
|
|
29
|
-
constructor(environment: Environment<TID>, documentStore?: DocumentStore);
|
|
30
|
-
private readonly documentStore;
|
|
31
|
-
/**
|
|
32
|
-
* Start the application and connect to the database
|
|
33
|
-
*/
|
|
34
|
-
start(delayReady?: boolean): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Stop the application
|
|
37
|
-
*/
|
|
38
|
-
stop(): Promise<void>;
|
|
39
|
-
}
|
|
40
11
|
//# sourceMappingURL=application-base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-base.d.ts","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/application-base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"application-base.d.ts","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/application-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -1,84 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseApplication = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
-
const brightchain_lib_1 = require("@brightchain/brightchain-lib");
|
|
6
|
-
const node_express_suite_1 = require("@digitaldefiance/node-express-suite");
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const appConstants_1 = require("./appConstants");
|
|
9
|
-
const block_document_store_1 = require("./datastore/block-document-store");
|
|
10
|
-
const environment_1 = require("./environment");
|
|
11
2
|
/**
|
|
12
|
-
*
|
|
3
|
+
* @deprecated This file is no longer used.
|
|
4
|
+
*
|
|
5
|
+
* The local BaseApplication class has been removed as part of the upstream
|
|
6
|
+
* Application refactor. BrightChain's App<TID> now extends the upstream
|
|
7
|
+
* Application from @digitaldefiance/node-express-suite directly, and
|
|
8
|
+
* manages DocumentStore/BlockDocumentStore internally.
|
|
9
|
+
*
|
|
10
|
+
* See: brightchain-api-lib/src/lib/application.ts
|
|
13
11
|
*/
|
|
14
|
-
class BaseApplication {
|
|
15
|
-
get environment() {
|
|
16
|
-
return this._environment;
|
|
17
|
-
}
|
|
18
|
-
get constants() {
|
|
19
|
-
return appConstants_1.AppConstants;
|
|
20
|
-
}
|
|
21
|
-
get db() {
|
|
22
|
-
return this.documentStore;
|
|
23
|
-
}
|
|
24
|
-
get services() {
|
|
25
|
-
if (!this._services) {
|
|
26
|
-
this._services = new node_express_suite_1.ServiceContainer();
|
|
27
|
-
}
|
|
28
|
-
return this._services;
|
|
29
|
-
}
|
|
30
|
-
get plugins() {
|
|
31
|
-
if (!this._plugins) {
|
|
32
|
-
this._plugins = new node_express_suite_1.PluginManager();
|
|
33
|
-
}
|
|
34
|
-
return this._plugins;
|
|
35
|
-
}
|
|
36
|
-
getModel(modelName) {
|
|
37
|
-
// Get a collection from the in-memory document store
|
|
38
|
-
const collection = this.documentStore.collection(modelName);
|
|
39
|
-
return collection;
|
|
40
|
-
}
|
|
41
|
-
reloadEnvironment(path, override = true) {
|
|
42
|
-
this._environment = new environment_1.Environment(path, false, override);
|
|
43
|
-
}
|
|
44
|
-
static get distDir() {
|
|
45
|
-
const cwd = process.cwd();
|
|
46
|
-
const distPath = (0, path_1.join)(cwd, 'dist');
|
|
47
|
-
return distPath;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get whether the application is ready to handle requests
|
|
51
|
-
*/
|
|
52
|
-
get ready() {
|
|
53
|
-
return this._ready;
|
|
54
|
-
}
|
|
55
|
-
constructor(environment, documentStore) {
|
|
56
|
-
this._ready = false;
|
|
57
|
-
this._environment = environment;
|
|
58
|
-
this.documentStore =
|
|
59
|
-
documentStore ??
|
|
60
|
-
new block_document_store_1.BlockDocumentStore(new brightchain_lib_1.MemoryBlockStore(brightchain_lib_1.BlockSize.Small));
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Start the application and connect to the database
|
|
64
|
-
*/
|
|
65
|
-
async start(delayReady) {
|
|
66
|
-
if (this._ready) {
|
|
67
|
-
console.error('Failed to start the application:', 'Application is already running');
|
|
68
|
-
const err = new Error('Application is already running');
|
|
69
|
-
if (process.env['NODE_ENV'] === 'test') {
|
|
70
|
-
throw err;
|
|
71
|
-
}
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
this._ready = delayReady ? false : true;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Stop the application
|
|
78
|
-
*/
|
|
79
|
-
async stop() {
|
|
80
|
-
this._ready = false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.BaseApplication = BaseApplication;
|
|
84
12
|
//# sourceMappingURL=application-base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-base.js","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/application-base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"application-base.js","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/application-base.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
|
package/src/lib/application.d.ts
CHANGED
|
@@ -1,27 +1,56 @@
|
|
|
1
1
|
import { IAvailabilityService, IDiscoveryProtocol, IReconciliationService } from '@brightchain/brightchain-lib';
|
|
2
2
|
import { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
3
|
-
import { Application } from 'express';
|
|
4
|
-
import {
|
|
3
|
+
import { IConstants, Application as UpstreamApplication } from '@digitaldefiance/node-express-suite';
|
|
4
|
+
import { DocumentCollection, DocumentRecord, DocumentStore } from './datastore/document-store';
|
|
5
5
|
import { Environment } from './environment';
|
|
6
|
+
import { IBrightChainInitResult } from './interfaces/brightchain-init-result';
|
|
6
7
|
import { ApiRouter } from './routers/api';
|
|
8
|
+
import { AppRouter } from './routers/app';
|
|
7
9
|
import { EventNotificationSystem } from './services/eventNotificationSystem';
|
|
8
10
|
import { MessagePassingService } from './services/messagePassingService';
|
|
9
11
|
import { WebSocketMessageServer } from './services/webSocketMessageServer';
|
|
10
12
|
/**
|
|
11
|
-
* Application class
|
|
13
|
+
* Application class for BrightChain.
|
|
14
|
+
*
|
|
15
|
+
* Extends the upstream Application from @digitaldefiance/node-express-suite,
|
|
16
|
+
* inheriting HTTP/HTTPS server lifecycle, greenlock/Let's Encrypt support,
|
|
17
|
+
* middleware initialization, and graceful shutdown.
|
|
18
|
+
*
|
|
19
|
+
* BrightChain-specific concerns (services, WebSocket, UPnP, EventNotificationSystem)
|
|
20
|
+
* are initialized after the upstream start() completes.
|
|
21
|
+
*
|
|
22
|
+
* Mongoose-related upstream parameters are satisfied with no-op stubs since
|
|
23
|
+
* BrightChain uses DocumentStore/BlockDocumentStore instead.
|
|
12
24
|
*/
|
|
13
|
-
export declare class App<TID extends PlatformID> extends
|
|
14
|
-
readonly expressApp: Application;
|
|
15
|
-
private server;
|
|
25
|
+
export declare class App<TID extends PlatformID> extends UpstreamApplication<IBrightChainInitResult<TID>, Record<string, never>, TID, Environment<TID>, IConstants, AppRouter<TID>> {
|
|
16
26
|
private controllers;
|
|
17
27
|
private readonly keyStorage;
|
|
28
|
+
private readonly _brightchainDocumentStore;
|
|
18
29
|
private apiRouter;
|
|
19
30
|
private eventSystem;
|
|
20
31
|
private wsServer;
|
|
21
32
|
private messagePassingService;
|
|
22
33
|
private upnpManager;
|
|
34
|
+
/**
|
|
35
|
+
* Captured HTTP server reference for WebSocket attachment.
|
|
36
|
+
* The upstream Application stores the server as a private field,
|
|
37
|
+
* so we intercept expressApp.listen() to capture it here.
|
|
38
|
+
*/
|
|
39
|
+
private _httpServer;
|
|
23
40
|
constructor(environment: Environment<TID>);
|
|
24
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Get the BrightChain document store.
|
|
43
|
+
* Overrides the upstream mongoose-based `db` getter since BrightChain
|
|
44
|
+
* uses its own BlockDocumentStore instead of mongoose.
|
|
45
|
+
*/
|
|
46
|
+
get db(): DocumentStore;
|
|
47
|
+
/**
|
|
48
|
+
* Get a collection from the BrightChain document store by name.
|
|
49
|
+
* Overrides the upstream mongoose-based `getModel()` to delegate
|
|
50
|
+
* to the BlockDocumentStore's collection() method.
|
|
51
|
+
*/
|
|
52
|
+
getModel<U extends DocumentRecord>(modelName: string): DocumentCollection<U>;
|
|
53
|
+
start(mongoUri?: string): Promise<void>;
|
|
25
54
|
stop(): Promise<void>;
|
|
26
55
|
getController<T = unknown>(name: string): T;
|
|
27
56
|
setController(name: string, controller: unknown): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/application.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EAEvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAGL,UAAU,EAEV,WAAW,IAAI,mBAAmB,EACnC,MAAM,qCAAqC,CAAC;AAI7C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAO3E;;;;;;;;;;;;GAYG;AACH,qBAAa,GAAG,CAAC,GAAG,SAAS,UAAU,CAAE,SAAQ,mBAAmB,CAClE,sBAAsB,CAAC,GAAG,CAAC,EAC3B,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACrB,GAAG,EACH,WAAW,CAAC,GAAG,CAAC,EAChB,UAAU,EACV,SAAS,CAAC,GAAG,CAAC,CACf;IACC,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAgB;IAC1D,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,QAAQ,CAAuC;IACvD,OAAO,CAAC,qBAAqB,CAAsC;IACnE,OAAO,CAAC,WAAW,CAA4B;IAE/C;;;;OAIG;IACH,OAAO,CAAC,WAAW,CAAuB;gBAE9B,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC;IA2BzC;;;;OAIG;IAEH,IAAoB,EAAE,IAAI,aAAa,CAEtC;IAED;;;;OAIG;IAEa,QAAQ,CAAC,CAAC,SAAS,cAAc,EAC/C,SAAS,EAAE,MAAM,GAChB,kBAAkB,CAAC,CAAC,CAAC;IAIF,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8FvC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA6BpC,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAI3C,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI;IAI7D;;;OAGG;IACI,YAAY,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI;IAI5C;;;OAGG;IACI,cAAc,IAAI,uBAAuB,GAAG,IAAI;IAIvD;;;OAGG;IACI,kBAAkB,IAAI,sBAAsB,GAAG,IAAI;IAI1D;;;;;OAKG;IACI,wBAAwB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;IAQrE;;;;;OAKG;IACI,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAO/D;;;;;OAKG;IACI,sBAAsB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAQlE;;;;;OAKG;IACI,wBAAwB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI;CAMvE"}
|
package/src/lib/application.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.App = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const brightchain_lib_1 = require("@brightchain/brightchain-lib");
|
|
6
|
-
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
7
5
|
const node_express_suite_1 = require("@digitaldefiance/node-express-suite");
|
|
8
|
-
const
|
|
9
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
10
|
-
const node_express_suite_2 = require("@digitaldefiance/node-express-suite");
|
|
11
|
-
const express_1 = tslib_1.__importDefault(require("express"));
|
|
12
|
-
const fs_1 = require("fs");
|
|
13
|
-
const https_1 = require("https");
|
|
14
|
-
const path_1 = require("path");
|
|
15
|
-
const application_base_1 = require("./application-base");
|
|
6
|
+
const appConstants_1 = require("./appConstants");
|
|
16
7
|
const block_document_store_factory_1 = require("./datastore/block-document-store-factory");
|
|
17
8
|
const blockStoreFactory_1 = require("./factories/blockStoreFactory");
|
|
18
9
|
const middlewares_1 = require("./middlewares");
|
|
@@ -21,136 +12,149 @@ const app_1 = require("./routers/app");
|
|
|
21
12
|
const services_1 = require("./services");
|
|
22
13
|
const eventNotificationSystem_1 = require("./services/eventNotificationSystem");
|
|
23
14
|
const webSocketMessageServer_1 = require("./services/webSocketMessageServer");
|
|
15
|
+
const upstream_stubs_1 = require("./upstream-stubs");
|
|
24
16
|
/**
|
|
25
|
-
* Application class
|
|
17
|
+
* Application class for BrightChain.
|
|
18
|
+
*
|
|
19
|
+
* Extends the upstream Application from @digitaldefiance/node-express-suite,
|
|
20
|
+
* inheriting HTTP/HTTPS server lifecycle, greenlock/Let's Encrypt support,
|
|
21
|
+
* middleware initialization, and graceful shutdown.
|
|
22
|
+
*
|
|
23
|
+
* BrightChain-specific concerns (services, WebSocket, UPnP, EventNotificationSystem)
|
|
24
|
+
* are initialized after the upstream start() completes.
|
|
25
|
+
*
|
|
26
|
+
* Mongoose-related upstream parameters are satisfied with no-op stubs since
|
|
27
|
+
* BrightChain uses DocumentStore/BlockDocumentStore instead.
|
|
26
28
|
*/
|
|
27
|
-
class App extends
|
|
29
|
+
class App extends node_express_suite_1.Application {
|
|
28
30
|
constructor(environment) {
|
|
29
|
-
super(environment,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
super(environment,
|
|
32
|
+
// apiRouterFactory — creates BrightChain's ApiRouter
|
|
33
|
+
// @ts-expect-error — App overrides db/getModel with DocumentStore types; runtime-compatible
|
|
34
|
+
(app) => new api_1.ApiRouter(app),
|
|
35
|
+
// schemaMapFactory — no-op, returns empty object (no mongoose models)
|
|
36
|
+
upstream_stubs_1.noOpSchemaMapFactory,
|
|
37
|
+
// databaseInitFunction — no-op, returns { success: true }
|
|
38
|
+
upstream_stubs_1.noOpDatabaseInitFunction,
|
|
39
|
+
// initResultHashFunction — no-op, returns 'no-mongoose'
|
|
40
|
+
upstream_stubs_1.noOpInitResultHashFunction,
|
|
41
|
+
// cspConfig — undefined; BrightChain's Middlewares.init handles CSP
|
|
42
|
+
undefined,
|
|
43
|
+
// constants
|
|
44
|
+
appConstants_1.AppConstants,
|
|
45
|
+
// appRouterFactory — creates BrightChain's AppRouter wrapping the ApiRouter
|
|
46
|
+
(apiRouter) => new app_1.AppRouter(apiRouter),
|
|
47
|
+
// customInitMiddleware — wrap Middlewares.init to match upstream signature
|
|
48
|
+
(app) => middlewares_1.Middlewares.init(app));
|
|
35
49
|
this.controllers = new Map();
|
|
36
50
|
this.apiRouter = null;
|
|
37
51
|
this.eventSystem = null;
|
|
38
52
|
this.wsServer = null;
|
|
39
53
|
this.messagePassingService = null;
|
|
40
54
|
this.upnpManager = null;
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Captured HTTP server reference for WebSocket attachment.
|
|
57
|
+
* The upstream Application stores the server as a private field,
|
|
58
|
+
* so we intercept expressApp.listen() to capture it here.
|
|
59
|
+
*/
|
|
60
|
+
this._httpServer = null;
|
|
43
61
|
this.keyStorage = services_1.SecureKeyStorage.getInstance();
|
|
62
|
+
this._brightchainDocumentStore = (0, block_document_store_factory_1.createBlockDocumentStore)({
|
|
63
|
+
useMemory: true,
|
|
64
|
+
});
|
|
44
65
|
}
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Get the BrightChain document store.
|
|
68
|
+
* Overrides the upstream mongoose-based `db` getter since BrightChain
|
|
69
|
+
* uses its own BlockDocumentStore instead of mongoose.
|
|
70
|
+
*/
|
|
71
|
+
// @ts-expect-error — intentional override: BrightChain uses DocumentStore, not mongoose
|
|
72
|
+
get db() {
|
|
73
|
+
return this._brightchainDocumentStore;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get a collection from the BrightChain document store by name.
|
|
77
|
+
* Overrides the upstream mongoose-based `getModel()` to delegate
|
|
78
|
+
* to the BlockDocumentStore's collection() method.
|
|
79
|
+
*/
|
|
80
|
+
// @ts-expect-error — intentional override: returns DocumentCollection, not mongoose Model
|
|
81
|
+
getModel(modelName) {
|
|
82
|
+
return this._brightchainDocumentStore.collection(modelName);
|
|
83
|
+
}
|
|
84
|
+
async start(mongoUri) {
|
|
85
|
+
// Intercept expressApp.listen to capture the HTTP server reference.
|
|
86
|
+
// The upstream Application creates the server internally via expressApp.listen(),
|
|
87
|
+
// but stores it in a private field we cannot access from a subclass.
|
|
88
|
+
const originalListen = this.expressApp.listen.bind(this.expressApp);
|
|
89
|
+
this.expressApp.listen = ((...args) => {
|
|
90
|
+
const server = originalListen(...args);
|
|
91
|
+
this._httpServer = server;
|
|
92
|
+
return server;
|
|
93
|
+
});
|
|
94
|
+
// Delegate to upstream — handles: middleware init, router setup, error handler,
|
|
95
|
+
// HTTP server on :port, greenlock/HTTPS on :443, dev-HTTPS, _ready = true
|
|
96
|
+
// Pass undefined to skip mongoose connection.
|
|
97
|
+
await super.start(mongoUri);
|
|
98
|
+
// Restore original listen to avoid side effects on subsequent calls
|
|
99
|
+
this.expressApp.listen = originalListen;
|
|
100
|
+
// ── BrightChain-specific initialization ──────────────────────────
|
|
101
|
+
await this.keyStorage.initializeFromEnvironment();
|
|
102
|
+
// Initialize core services
|
|
103
|
+
const blockStore = blockStoreFactory_1.BlockStoreFactory.createMemoryStore({
|
|
104
|
+
blockSize: brightchain_lib_1.BlockSize.Small,
|
|
105
|
+
});
|
|
106
|
+
const memberStore = new brightchain_lib_1.MemberStore(blockStore);
|
|
107
|
+
const energyStore = new brightchain_lib_1.EnergyAccountStore();
|
|
108
|
+
const energyLedger = new brightchain_lib_1.EnergyLedger();
|
|
109
|
+
// @ts-expect-error — App overrides db/getModel with DocumentStore types; runtime-compatible
|
|
110
|
+
const emailService = new services_1.EmailService(this);
|
|
111
|
+
const authService = new services_1.AuthService(
|
|
112
|
+
// @ts-expect-error — App overrides db/getModel with DocumentStore types; runtime-compatible
|
|
113
|
+
this, memberStore, energyStore, emailService, this.environment.jwtSecret);
|
|
114
|
+
// Register services in the upstream ServiceContainer
|
|
115
|
+
this.services.register('memberStore', () => memberStore);
|
|
116
|
+
this.services.register('energyStore', () => energyStore);
|
|
117
|
+
this.services.register('energyLedger', () => energyLedger);
|
|
118
|
+
this.services.register('emailService', () => emailService);
|
|
119
|
+
this.services.register('auth', () => authService);
|
|
120
|
+
// EventNotificationSystem for WebSocket events
|
|
121
|
+
this.eventSystem = new eventNotificationSystem_1.EventNotificationSystem();
|
|
122
|
+
this.services.register('eventSystem', () => this.eventSystem);
|
|
123
|
+
// WebSocket — attach to the captured HTTP server
|
|
124
|
+
if (this._httpServer) {
|
|
125
|
+
this.wsServer = new webSocketMessageServer_1.WebSocketMessageServer(this._httpServer, false);
|
|
126
|
+
this.services.register('wsServer', () => this.wsServer);
|
|
127
|
+
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ ready ] WebSocket server initialized');
|
|
128
|
+
}
|
|
129
|
+
// Wire EventNotificationSystem to SyncController via the apiRouter
|
|
130
|
+
if (this.apiRouter) {
|
|
131
|
+
this.apiRouter.setSyncEventSystem(this.eventSystem);
|
|
132
|
+
}
|
|
133
|
+
// UPnP port mapping (non-fatal on failure)
|
|
47
134
|
try {
|
|
48
|
-
if (this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// Initialize services
|
|
54
|
-
const blockStore = blockStoreFactory_1.BlockStoreFactory.createMemoryStore({
|
|
55
|
-
blockSize: brightchain_lib_1.BlockSize.Small,
|
|
56
|
-
});
|
|
57
|
-
const memberStore = new brightchain_lib_1.MemberStore(blockStore);
|
|
58
|
-
const energyStore = new brightchain_lib_1.EnergyAccountStore();
|
|
59
|
-
const energyLedger = new brightchain_lib_1.EnergyLedger();
|
|
60
|
-
const emailService = new services_1.EmailService(this);
|
|
61
|
-
const authService = new services_1.AuthService(this, memberStore, energyStore, emailService, this.environment.jwtSecret);
|
|
62
|
-
// Register services
|
|
63
|
-
this.services.register('memberStore', () => memberStore);
|
|
64
|
-
this.services.register('energyStore', () => energyStore);
|
|
65
|
-
this.services.register('energyLedger', () => energyLedger);
|
|
66
|
-
this.services.register('emailService', () => emailService);
|
|
67
|
-
this.services.register('auth', () => authService);
|
|
68
|
-
// Initialize EventNotificationSystem for WebSocket events
|
|
69
|
-
// @requirements 5.1, 5.2, 5.4
|
|
70
|
-
this.eventSystem = new eventNotificationSystem_1.EventNotificationSystem();
|
|
71
|
-
this.services.register('eventSystem', () => this.eventSystem);
|
|
72
|
-
middlewares_1.Middlewares.init(this.expressApp);
|
|
73
|
-
const apiRouter = new api_1.ApiRouter(this);
|
|
74
|
-
this.apiRouter = apiRouter;
|
|
75
|
-
const appRouter = new app_1.AppRouter(apiRouter);
|
|
76
|
-
// Wire EventNotificationSystem to SyncController for replication events
|
|
77
|
-
// @requirements 4.5
|
|
78
|
-
apiRouter.setSyncEventSystem(this.eventSystem);
|
|
79
|
-
appRouter.init(this.expressApp);
|
|
80
|
-
this.expressApp.use((err, req, res, next) => {
|
|
81
|
-
const handleableError = err instanceof i18n_lib_1.HandleableError
|
|
82
|
-
? err
|
|
83
|
-
: new i18n_lib_1.HandleableError(new Error(err.message ||
|
|
84
|
-
(0, brightchain_lib_1.translate)(brightchain_lib_1.BrightChainStrings.Error_Unexpected_Error)), { cause: err });
|
|
85
|
-
(0, node_express_suite_1.handleError)(handleableError, res, node_express_suite_1.sendApiMessageResponse, next);
|
|
86
|
-
});
|
|
87
|
-
const serversReady = [];
|
|
88
|
-
serversReady.push(new Promise((resolve) => {
|
|
89
|
-
this.server = this.expressApp.listen(this.environment.port, this.environment.host, () => {
|
|
90
|
-
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', `[ ready ] http://${this.environment.host}:${this.environment.port}`);
|
|
91
|
-
// Initialize WebSocket server after HTTP server is ready
|
|
92
|
-
// @requirements 5.1
|
|
93
|
-
if (this.server) {
|
|
94
|
-
this.wsServer = new webSocketMessageServer_1.WebSocketMessageServer(this.server, false);
|
|
95
|
-
this.services.register('wsServer', () => this.wsServer);
|
|
96
|
-
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ ready ] WebSocket server initialized');
|
|
97
|
-
}
|
|
98
|
-
resolve();
|
|
99
|
-
});
|
|
100
|
-
}));
|
|
101
|
-
if (this.environment.httpsDevCertRoot) {
|
|
102
|
-
try {
|
|
103
|
-
const certPath = (0, path_1.resolve)(this.environment.httpsDevCertRoot + '.pem');
|
|
104
|
-
const keyPath = (0, path_1.resolve)(this.environment.httpsDevCertRoot + '-key.pem');
|
|
105
|
-
const options = {
|
|
106
|
-
key: (0, fs_1.readFileSync)(keyPath),
|
|
107
|
-
cert: (0, fs_1.readFileSync)(certPath),
|
|
108
|
-
};
|
|
109
|
-
serversReady.push(new Promise((resolve) => {
|
|
110
|
-
(0, https_1.createServer)(options, this.expressApp).listen(this.environment.httpsDevPort, () => {
|
|
111
|
-
console.log(`[ ${(0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_Ready)} ] https://${this.environment.host}:${this.environment.httpsDevPort}`);
|
|
112
|
-
resolve();
|
|
113
|
-
});
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
console.error('Failed to start HTTPS server:', err);
|
|
118
|
-
}
|
|
135
|
+
if (this.environment.upnp?.enabled) {
|
|
136
|
+
this.upnpManager = new node_express_suite_1.UpnpManager(this.environment.upnp);
|
|
137
|
+
await this.upnpManager.initialize();
|
|
138
|
+
this.services.register('upnpManager', () => this.upnpManager);
|
|
139
|
+
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ ready ] UPnP port mapping initialized');
|
|
119
140
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
try {
|
|
123
|
-
if (this.environment.upnp.enabled) {
|
|
124
|
-
this.upnpManager = new node_express_suite_2.UpnpManager(this.environment.upnp);
|
|
125
|
-
await this.upnpManager.initialize();
|
|
126
|
-
this.services.register('upnpManager', () => this.upnpManager);
|
|
127
|
-
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ ready ] UPnP port mapping initialized');
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ info ] UPnP port mapping disabled');
|
|
131
|
-
}
|
|
141
|
+
else {
|
|
142
|
+
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ info ] UPnP port mapping disabled');
|
|
132
143
|
}
|
|
133
|
-
catch (upnpErr) {
|
|
134
|
-
console.warn('[ warning ] UPnP initialization failed, continuing without port mapping:', upnpErr);
|
|
135
|
-
}
|
|
136
|
-
this._ready = true;
|
|
137
144
|
}
|
|
138
|
-
catch (
|
|
139
|
-
console.
|
|
140
|
-
if (process.env['NODE_ENV'] === 'test') {
|
|
141
|
-
throw err;
|
|
142
|
-
}
|
|
143
|
-
process.exit(1);
|
|
145
|
+
catch (upnpErr) {
|
|
146
|
+
console.warn('[ warning ] UPnP initialization failed, continuing without port mapping:', upnpErr);
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
async stop() {
|
|
147
|
-
//
|
|
150
|
+
// BrightChain-specific cleanup first, then delegate to upstream
|
|
151
|
+
// Shutdown UPnP port mappings
|
|
148
152
|
if (this.upnpManager) {
|
|
149
153
|
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ stopping ] UPnP port mapping');
|
|
150
154
|
await this.upnpManager.shutdown();
|
|
151
155
|
this.upnpManager = null;
|
|
152
156
|
}
|
|
153
|
-
// Close WebSocket server
|
|
157
|
+
// Close WebSocket server
|
|
154
158
|
if (this.wsServer) {
|
|
155
159
|
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ stopping ] WebSocket server');
|
|
156
160
|
await new Promise((resolve) => {
|
|
@@ -158,28 +162,13 @@ class App extends application_base_1.BaseApplication {
|
|
|
158
162
|
});
|
|
159
163
|
this.wsServer = null;
|
|
160
164
|
}
|
|
161
|
-
|
|
162
|
-
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ stopping ] Application server');
|
|
163
|
-
await new Promise((resolve, reject) => {
|
|
164
|
-
this.server.closeAllConnections?.();
|
|
165
|
-
this.server.close((err) => {
|
|
166
|
-
if (err) {
|
|
167
|
-
reject(err);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
resolve();
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
this.server = null;
|
|
175
|
-
}
|
|
176
|
-
// Clean up other services
|
|
165
|
+
// Clean up BrightChain services
|
|
177
166
|
this.eventSystem = null;
|
|
178
167
|
this.messagePassingService = null;
|
|
179
168
|
this.apiRouter = null;
|
|
169
|
+
this._httpServer = null;
|
|
170
|
+
// Upstream handles: greenlockManager.stop(), server.close(), db disconnect, _ready = false
|
|
180
171
|
await super.stop();
|
|
181
|
-
this._ready = false;
|
|
182
|
-
(0, node_express_suite_1.debugLog)(this.environment.debug, 'log', '[ stopped ] Application server and database connections');
|
|
183
172
|
}
|
|
184
173
|
getController(name) {
|
|
185
174
|
return this.controllers.get(name);
|