@digitaldefiance/node-express-suite 3.16.0 → 3.18.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 +1 -1
- package/src/__tests__/helpers/setup-test-env.d.ts.map +1 -1
- package/src/__tests__/helpers/setup-test-env.js.map +1 -1
- package/src/application-base.d.ts +19 -58
- package/src/application-base.d.ts.map +1 -1
- package/src/application-base.js +38 -154
- package/src/application-base.js.map +1 -1
- package/src/application.d.ts +4 -4
- package/src/application.d.ts.map +1 -1
- package/src/application.js +3 -3
- package/src/application.js.map +1 -1
- package/src/builders/application-builder.d.ts +2 -2
- package/src/builders/application-builder.d.ts.map +1 -1
- package/src/environment.d.ts +5 -0
- package/src/environment.d.ts.map +1 -1
- package/src/environment.js +8 -0
- package/src/environment.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/interfaces/environment.d.ts +7 -0
- package/src/interfaces/environment.d.ts.map +1 -1
- package/src/mongo-application-base.d.ts +81 -0
- package/src/mongo-application-base.d.ts.map +1 -0
- package/src/mongo-application-base.js +211 -0
- package/src/mongo-application-base.js.map +1 -0
- package/src/services/backup-code.d.ts +2 -2
- package/src/services/backup-code.d.ts.map +1 -1
- package/src/services/jwt.d.ts +2 -2
- package/src/services/jwt.d.ts.map +1 -1
- package/src/services/mongoose-document-store.d.ts +2 -2
- package/src/services/mongoose-document-store.d.ts.map +1 -1
- package/src/services/mongoose-document-store.js.map +1 -1
- package/src/services/role.d.ts +2 -2
- package/src/services/role.d.ts.map +1 -1
- package/src/services/role.js.map +1 -1
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-test-env.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-express-suite/src/__tests__/helpers/setup-test-env.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"setup-test-env.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-express-suite/src/__tests__/helpers/setup-test-env.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,YAAY,EACZ,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,wBAAsB,oBAAoB,CACxC,GAAG,SAAS,UAAU,GAAG,MAAM,EAC/B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM,CACjE,MAAM,EACN,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CACxB,EACD,UAAU,SAAS,UAAU,GAAG,UAAU,EAC1C,UAAU,SAAS,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,EAElD,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC,GAAG,CAAC,EAC7D,gBAAgB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,EACxE,gBAAgB,GAAE,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,KAAK,UACV,EACxC,oBAAoB,GAAE,OAAO,cAA+B,EAC5D,WAAW,CAAC,EAAE,MAAM,EACpB,oBAAoB,CAAC,EAAE,CACrB,WAAW,EAAE,YAAY,CAAC,GAAG,CAAC,KAC3B,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EACrD,sBAAsB,CAAC,EAAE,CAAC,WAAW,EAAE,iBAAiB,CAAC,GAAG,CAAC,KAAK,MAAM,EACxE,SAAS,GAAE,UAAU,GAAG,aAAa,GAAG,YAWvC,GACA,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CA+IhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-test-env.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-express-suite/src/__tests__/helpers/setup-test-env.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"setup-test-env.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-express-suite/src/__tests__/helpers/setup-test-env.ts"],"names":[],"mappings":";;AAyBA,oDA+KC;AAxMD,wDAImC;AAInC,mDAAgD;AAEhD,mDAAgD;AAShD,6DAAwD;AACxD,2CAAsD;AACtD,6CAA+D;AAIxD,KAAK,UAAU,oBAAoB,CASxC,SAAqB,EACrB,gBAA6D,EAC7D,gBAAwE,EACxE,mBAA+D,CAAC,SAAS,EAAE,EAAE,CAC3E,IAAI,mBAAS,CAAC,SAAS,CAAe,EACxC,uBAA8C,iCAAc,EAC5D,WAAoB,EACpB,oBAEqD,EACrD,sBAAwE,EACxE,YAAuD;IACrD,aAAa,EAAE,EAAE;IACjB,GAAG,EAAE;QACH,UAAU,EAAE,EAA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AAC,KAAK,CAAC,6BAA6B;iBAC9D;gBACH,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;QAEF,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;YACpE,2CAA2C;YAC3C,MAAM,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE;iBAC/B,KAAK,EAAE;iBACP,OAAO,CAAC,OAAO,CAAC;iBAChB,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,+CAA+C,EAC/C,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAClC,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QAC1C,MAAM,KAAK,CAAC;IACd,CAAC;IAED,sEAAsE;IACtE,OAAO,CAAC,GAAG,CAAC,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC;IAE3D,OAAO;QACL,WAAW;QACX,WAAW,EAAE,WAAW,CAAC,WAAY;QACrC,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,GAAI;QAC5C,WAAW;QACX,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,WAAY;KAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
* Delegates database operations to an IDatabase instance
|
|
2
|
+
* @fileoverview Database-agnostic base application class.
|
|
3
|
+
* Delegates database operations to an IDatabase instance.
|
|
4
|
+
* For MongoDB/Mongoose-specific functionality, see MongoApplicationBase.
|
|
4
5
|
* @module application-base
|
|
5
6
|
*/
|
|
6
7
|
import type { BsonDocument, ICollection, IDatabase, IDatabaseLifecycleHooks } from './interfaces/storage';
|
|
7
|
-
import { Model } from '@digitaldefiance/mongoose-types';
|
|
8
|
-
import mongoose from '@digitaldefiance/mongoose-types';
|
|
9
|
-
import { MongoMemoryReplSet } from 'mongodb-memory-server';
|
|
10
8
|
import { ServiceContainer } from './container';
|
|
11
|
-
import { IBaseDocument } from './documents/base';
|
|
12
9
|
import { Environment } from './environment';
|
|
13
|
-
import {
|
|
10
|
+
import { IApplication } from './interfaces/application';
|
|
14
11
|
import { IAuthenticationProvider } from './interfaces/authentication-provider';
|
|
15
12
|
import { IConstants } from './interfaces/constants';
|
|
16
|
-
import { IDocumentStore } from './interfaces/document-store';
|
|
17
13
|
import { PluginManager } from './plugins';
|
|
18
|
-
import { SchemaMap } from './types';
|
|
19
14
|
import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
20
15
|
/**
|
|
21
|
-
*
|
|
22
|
-
* Accepts an IDatabase
|
|
23
|
-
*
|
|
24
|
-
*
|
|
16
|
+
* Database-agnostic base application class.
|
|
17
|
+
* Accepts an IDatabase for storage operations and optional lifecycle hooks
|
|
18
|
+
* for dev store provisioning, URI validation, and database initialization.
|
|
19
|
+
*
|
|
20
|
+
* For MongoDB/Mongoose-specific functionality (IDocumentStore, schemaMap,
|
|
21
|
+
* getModel, db), use MongoApplicationBase which extends this class.
|
|
25
22
|
*/
|
|
26
|
-
export declare class BaseApplication<TID extends PlatformID,
|
|
23
|
+
export declare class BaseApplication<TID extends PlatformID, TInitResults = unknown, TConstants extends IConstants = IConstants> implements IApplication<TID> {
|
|
27
24
|
/**
|
|
28
25
|
* Application environment
|
|
29
26
|
*/
|
|
@@ -34,17 +31,10 @@ export declare class BaseApplication<TID extends PlatformID, TModelDocs extends
|
|
|
34
31
|
private _constants;
|
|
35
32
|
/**
|
|
36
33
|
* The IDatabase instance for storage-agnostic database operations.
|
|
37
|
-
* Set when an IDatabase is passed to the constructor.
|
|
38
34
|
*/
|
|
39
|
-
protected readonly _database: IDatabase
|
|
35
|
+
protected readonly _database: IDatabase;
|
|
40
36
|
/**
|
|
41
|
-
*
|
|
42
|
-
* Set when a legacy IDocumentStore is passed to the constructor.
|
|
43
|
-
* @deprecated Prefer _database (IDatabase) for new code.
|
|
44
|
-
*/
|
|
45
|
-
protected readonly _documentStore: IDocumentStore<TID, TModelDocs> | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Optional lifecycle hooks for database initialization on the IDatabase path.
|
|
37
|
+
* Optional lifecycle hooks for database initialization.
|
|
48
38
|
*/
|
|
49
39
|
protected readonly _lifecycleHooks: IDatabaseLifecycleHooks<TInitResults> | undefined;
|
|
50
40
|
/**
|
|
@@ -64,11 +54,6 @@ export declare class BaseApplication<TID extends PlatformID, TModelDocs extends
|
|
|
64
54
|
* Get the path to the dist directory
|
|
65
55
|
*/
|
|
66
56
|
static get distDir(): string;
|
|
67
|
-
/**
|
|
68
|
-
* Schema map for all models, delegated to the document store.
|
|
69
|
-
* Only available when a legacy IDocumentStore is used.
|
|
70
|
-
*/
|
|
71
|
-
get schemaMap(): SchemaMap<TID, TModelDocs>;
|
|
72
57
|
/**
|
|
73
58
|
* Flag indicating whether the application is ready to handle requests
|
|
74
59
|
*/
|
|
@@ -82,60 +67,36 @@ export declare class BaseApplication<TID extends PlatformID, TModelDocs extends
|
|
|
82
67
|
*/
|
|
83
68
|
readonly plugins: PluginManager<TID>;
|
|
84
69
|
/**
|
|
85
|
-
* Get the
|
|
86
|
-
* @deprecated Use database (IDatabase) or documentStore instead for storage-agnostic access.
|
|
87
|
-
*/
|
|
88
|
-
get db(): typeof mongoose;
|
|
89
|
-
/**
|
|
90
|
-
* Get the IDatabase instance, if one was provided.
|
|
70
|
+
* Get the IDatabase instance.
|
|
91
71
|
*/
|
|
92
|
-
get database(): IDatabase
|
|
72
|
+
get database(): IDatabase;
|
|
93
73
|
/**
|
|
94
74
|
* Authentication provider for storage-agnostic user lookup and credential verification.
|
|
95
75
|
* Subclasses can override this to provide a custom authentication provider.
|
|
96
|
-
* By default, returns undefined — Mongo-backed apps should set this in their constructor
|
|
97
|
-
* or override this getter.
|
|
98
76
|
*/
|
|
99
77
|
private _authProvider;
|
|
100
78
|
get authProvider(): IAuthenticationProvider<TID> | undefined;
|
|
101
79
|
set authProvider(provider: IAuthenticationProvider<TID> | undefined);
|
|
102
|
-
/**
|
|
103
|
-
* Get the injected document store.
|
|
104
|
-
* @deprecated Prefer database (IDatabase) for new code.
|
|
105
|
-
*/
|
|
106
|
-
get documentStore(): IDocumentStore<TID, TModelDocs> | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* Get the in-memory MongoDB instance (if any), delegated to the document store.
|
|
109
|
-
* Only available when a legacy IDocumentStore is used.
|
|
110
|
-
*/
|
|
111
|
-
get devDatabase(): MongoMemoryReplSet | undefined;
|
|
112
80
|
/**
|
|
113
81
|
* Get whether the application is ready to handle requests
|
|
114
82
|
*/
|
|
115
83
|
get ready(): boolean;
|
|
116
|
-
constructor(environment: Environment<TID>,
|
|
84
|
+
constructor(environment: Environment<TID>, database: IDatabase, constants?: TConstants, lifecycleHooks?: IDatabaseLifecycleHooks<TInitResults>);
|
|
117
85
|
/**
|
|
118
86
|
* Start the application and connect to the database.
|
|
119
|
-
* Delegates connection to IDatabase
|
|
87
|
+
* Delegates connection to the IDatabase instance.
|
|
120
88
|
*/
|
|
121
|
-
start(
|
|
89
|
+
start(uri?: string, delayReady?: boolean): Promise<void>;
|
|
122
90
|
/**
|
|
123
91
|
* Stop the application.
|
|
124
|
-
* Delegates disconnection to IDatabase
|
|
92
|
+
* Delegates disconnection to the IDatabase instance.
|
|
125
93
|
*/
|
|
126
94
|
stop(): Promise<void>;
|
|
127
95
|
/**
|
|
128
96
|
* Get a collection by name via the IDatabase interface.
|
|
129
97
|
* @param name Name of the collection
|
|
130
98
|
* @returns ICollection<T> for the named collection
|
|
131
|
-
* @throws if no IDatabase was provided
|
|
132
99
|
*/
|
|
133
100
|
getCollection<T extends BsonDocument>(name: string): ICollection<T>;
|
|
134
|
-
/**
|
|
135
|
-
* Get a model by name, delegated to the legacy document store.
|
|
136
|
-
* @deprecated Use getCollection<T>(name) with IDatabase instead.
|
|
137
|
-
* @param modelName Name of the model
|
|
138
|
-
*/
|
|
139
|
-
getModel<T extends IBaseDocument<any, TID>>(modelName: string): Model<T>;
|
|
140
101
|
}
|
|
141
102
|
//# sourceMappingURL=application-base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-base.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-express-suite/src/application-base.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"application-base.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-express-suite/src/application-base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;;;;;GAOG;AACH,qBAAa,eAAe,CAC1B,GAAG,SAAS,UAAU,EACtB,YAAY,GAAG,OAAO,EACtB,UAAU,SAAS,UAAU,GAAG,UAAU,CAC1C,YAAW,YAAY,CAAC,GAAG,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,YAAY,CAAmB;IAEvC;;OAEG;IACH,OAAO,CAAC,UAAU,CAAa;IAE/B;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SA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AAC,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC;CAG3E"}
|
package/src/application-base.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* @fileoverview
|
|
4
|
-
* Delegates database operations to an IDatabase instance
|
|
3
|
+
* @fileoverview Database-agnostic base application class.
|
|
4
|
+
* Delegates database operations to an IDatabase instance.
|
|
5
|
+
* For MongoDB/Mongoose-specific functionality, see MongoApplicationBase.
|
|
5
6
|
* @module application-base
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -11,26 +12,14 @@ const path_1 = require("path");
|
|
|
11
12
|
const container_1 = require("./container");
|
|
12
13
|
const environment_1 = require("./environment");
|
|
13
14
|
const plugins_1 = require("./plugins");
|
|
14
|
-
const mongoose_document_store_1 = require("./services/mongoose-document-store");
|
|
15
|
-
const default_mongo_uri_validator_1 = require("./utils/default-mongo-uri-validator");
|
|
16
15
|
const utils_1 = require("./utils");
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
'collection' in value &&
|
|
25
|
-
'startSession' in value &&
|
|
26
|
-
typeof value['collection'] === 'function' &&
|
|
27
|
-
typeof value['startSession'] === 'function');
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Base Application class with core functionality.
|
|
31
|
-
* Accepts an IDatabase (preferred) or legacy IDocumentStore for backward compatibility.
|
|
32
|
-
* When an IDatabase is provided, database lifecycle is managed through the IDatabase contract.
|
|
33
|
-
* When a legacy IDocumentStore is provided, it is used directly for backward compatibility.
|
|
17
|
+
* Database-agnostic base application class.
|
|
18
|
+
* Accepts an IDatabase for storage operations and optional lifecycle hooks
|
|
19
|
+
* for dev store provisioning, URI validation, and database initialization.
|
|
20
|
+
*
|
|
21
|
+
* For MongoDB/Mongoose-specific functionality (IDocumentStore, schemaMap,
|
|
22
|
+
* getModel, db), use MongoApplicationBase which extends this class.
|
|
34
23
|
*/
|
|
35
24
|
class BaseApplication {
|
|
36
25
|
/**
|
|
@@ -43,17 +32,10 @@ class BaseApplication {
|
|
|
43
32
|
_constants;
|
|
44
33
|
/**
|
|
45
34
|
* The IDatabase instance for storage-agnostic database operations.
|
|
46
|
-
* Set when an IDatabase is passed to the constructor.
|
|
47
35
|
*/
|
|
48
36
|
_database;
|
|
49
37
|
/**
|
|
50
|
-
*
|
|
51
|
-
* Set when a legacy IDocumentStore is passed to the constructor.
|
|
52
|
-
* @deprecated Prefer _database (IDatabase) for new code.
|
|
53
|
-
*/
|
|
54
|
-
_documentStore;
|
|
55
|
-
/**
|
|
56
|
-
* Optional lifecycle hooks for database initialization on the IDatabase path.
|
|
38
|
+
* Optional lifecycle hooks for database initialization.
|
|
57
39
|
*/
|
|
58
40
|
_lifecycleHooks;
|
|
59
41
|
/**
|
|
@@ -83,20 +65,6 @@ class BaseApplication {
|
|
|
83
65
|
const distPath = (0, path_1.join)(cwd, 'dist');
|
|
84
66
|
return distPath;
|
|
85
67
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Schema map for all models, delegated to the document store.
|
|
88
|
-
* Only available when a legacy IDocumentStore is used.
|
|
89
|
-
*/
|
|
90
|
-
get schemaMap() {
|
|
91
|
-
if (!this._documentStore) {
|
|
92
|
-
throw new suite_core_lib_1.TranslatableSuiteError(suite_core_lib_1.SuiteCoreStringKey.Admin_Error_SchemaMapIsNotLoadedYet);
|
|
93
|
-
}
|
|
94
|
-
const map = this._documentStore.schemaMap;
|
|
95
|
-
if (!map) {
|
|
96
|
-
throw new suite_core_lib_1.TranslatableSuiteError(suite_core_lib_1.SuiteCoreStringKey.Admin_Error_SchemaMapIsNotLoadedYet);
|
|
97
|
-
}
|
|
98
|
-
return map;
|
|
99
|
-
}
|
|
100
68
|
/**
|
|
101
69
|
* Flag indicating whether the application is ready to handle requests
|
|
102
70
|
*/
|
|
@@ -110,17 +78,7 @@ class BaseApplication {
|
|
|
110
78
|
*/
|
|
111
79
|
plugins;
|
|
112
80
|
/**
|
|
113
|
-
* Get the
|
|
114
|
-
* @deprecated Use database (IDatabase) or documentStore instead for storage-agnostic access.
|
|
115
|
-
*/
|
|
116
|
-
get db() {
|
|
117
|
-
if (this._documentStore instanceof mongoose_document_store_1.MongooseDocumentStore) {
|
|
118
|
-
return this._documentStore.db;
|
|
119
|
-
}
|
|
120
|
-
throw new suite_core_lib_1.TranslatableSuiteError(suite_core_lib_1.SuiteCoreStringKey.Admin_Error_DatabaseNotConnectedYet);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Get the IDatabase instance, if one was provided.
|
|
81
|
+
* Get the IDatabase instance.
|
|
124
82
|
*/
|
|
125
83
|
get database() {
|
|
126
84
|
return this._database;
|
|
@@ -128,8 +86,6 @@ class BaseApplication {
|
|
|
128
86
|
/**
|
|
129
87
|
* Authentication provider for storage-agnostic user lookup and credential verification.
|
|
130
88
|
* Subclasses can override this to provide a custom authentication provider.
|
|
131
|
-
* By default, returns undefined — Mongo-backed apps should set this in their constructor
|
|
132
|
-
* or override this getter.
|
|
133
89
|
*/
|
|
134
90
|
_authProvider;
|
|
135
91
|
get authProvider() {
|
|
@@ -138,50 +94,26 @@ class BaseApplication {
|
|
|
138
94
|
set authProvider(provider) {
|
|
139
95
|
this._authProvider = provider;
|
|
140
96
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Get the injected document store.
|
|
143
|
-
* @deprecated Prefer database (IDatabase) for new code.
|
|
144
|
-
*/
|
|
145
|
-
get documentStore() {
|
|
146
|
-
return this._documentStore;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Get the in-memory MongoDB instance (if any), delegated to the document store.
|
|
150
|
-
* Only available when a legacy IDocumentStore is used.
|
|
151
|
-
*/
|
|
152
|
-
get devDatabase() {
|
|
153
|
-
return this._documentStore?.devDatabase;
|
|
154
|
-
}
|
|
155
97
|
/**
|
|
156
98
|
* Get whether the application is ready to handle requests
|
|
157
99
|
*/
|
|
158
100
|
get ready() {
|
|
159
101
|
return this._ready;
|
|
160
102
|
}
|
|
161
|
-
constructor(environment,
|
|
103
|
+
constructor(environment, database, constants = suite_core_lib_1.Constants, lifecycleHooks) {
|
|
162
104
|
this._ready = false;
|
|
163
105
|
this._environment = environment;
|
|
164
106
|
this._constants = constants;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
this._database = databaseOrStore;
|
|
168
|
-
this._documentStore = undefined;
|
|
169
|
-
this._lifecycleHooks = lifecycleHooks;
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
this._database = undefined;
|
|
173
|
-
this._documentStore = databaseOrStore;
|
|
174
|
-
// Lifecycle hooks are only used on the IDatabase path
|
|
175
|
-
this._lifecycleHooks = undefined;
|
|
176
|
-
}
|
|
107
|
+
this._database = database;
|
|
108
|
+
this._lifecycleHooks = lifecycleHooks;
|
|
177
109
|
this.services = new container_1.ServiceContainer();
|
|
178
110
|
this.plugins = new plugins_1.PluginManager();
|
|
179
111
|
}
|
|
180
112
|
/**
|
|
181
113
|
* Start the application and connect to the database.
|
|
182
|
-
* Delegates connection to IDatabase
|
|
114
|
+
* Delegates connection to the IDatabase instance.
|
|
183
115
|
*/
|
|
184
|
-
async start(
|
|
116
|
+
async start(uri, delayReady) {
|
|
185
117
|
if (this._ready) {
|
|
186
118
|
console.error('Failed to start the application:', 'Application is already running');
|
|
187
119
|
const err = new Error('Application is already running');
|
|
@@ -190,46 +122,24 @@ class BaseApplication {
|
|
|
190
122
|
}
|
|
191
123
|
process.exit(1);
|
|
192
124
|
}
|
|
193
|
-
//
|
|
194
|
-
if (this.
|
|
195
|
-
|
|
196
|
-
if (this._documentStore.setupDevStore) {
|
|
197
|
-
mongoUri = (await this._documentStore.setupDevStore());
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
// IDatabase path: handle dev store setup via lifecycle hooks
|
|
202
|
-
if (this._database &&
|
|
203
|
-
this._lifecycleHooks?.setupDevStore &&
|
|
204
|
-
this._environment.devDatabase) {
|
|
205
|
-
mongoUri = await this._lifecycleHooks.setupDevStore();
|
|
125
|
+
// Handle dev store setup via lifecycle hooks
|
|
126
|
+
if (this._lifecycleHooks?.setupDevStore && this._environment.devDatabase) {
|
|
127
|
+
uri = await this._lifecycleHooks.setupDevStore();
|
|
206
128
|
this._devStoreProvisioned = true;
|
|
207
129
|
}
|
|
208
130
|
try {
|
|
209
|
-
const
|
|
210
|
-
if
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (this._lifecycleHooks?.validateUri) {
|
|
216
|
-
this._lifecycleHooks.validateUri(uri);
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
(0, default_mongo_uri_validator_1.defaultMongoUriValidator)(uri, this._environment.production);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
await this._database.connect(uri);
|
|
223
|
-
}
|
|
224
|
-
else if (this._documentStore) {
|
|
225
|
-
// Legacy IDocumentStore path — always requires a URI
|
|
226
|
-
await this._documentStore.connect(uri);
|
|
131
|
+
const resolvedUri = uri ?? this.environment.databaseUri;
|
|
132
|
+
// Only validate/connect if a URI was provided.
|
|
133
|
+
// Non-Mongo databases (e.g. BrightChainDb) manage their own connection
|
|
134
|
+
// internally and do not need a URI passed from the environment.
|
|
135
|
+
if (resolvedUri && this._lifecycleHooks?.validateUri) {
|
|
136
|
+
this._lifecycleHooks.validateUri(resolvedUri);
|
|
227
137
|
}
|
|
138
|
+
await this._database.connect(resolvedUri);
|
|
228
139
|
// Initialize plugins
|
|
229
140
|
await this.plugins.initAll(this);
|
|
230
|
-
//
|
|
231
|
-
if (this.
|
|
232
|
-
this._lifecycleHooks?.initializeDatabase &&
|
|
141
|
+
// Run database initialization hook in dev mode
|
|
142
|
+
if (this._lifecycleHooks?.initializeDatabase &&
|
|
233
143
|
this._environment.devDatabase) {
|
|
234
144
|
const initTimeoutMs = 300000; // 5 minutes
|
|
235
145
|
const engine = (0, suite_core_lib_1.getSuiteCoreI18nEngine)({ constants: this._constants });
|
|
@@ -275,30 +185,20 @@ class BaseApplication {
|
|
|
275
185
|
}
|
|
276
186
|
/**
|
|
277
187
|
* Stop the application.
|
|
278
|
-
* Delegates disconnection to IDatabase
|
|
188
|
+
* Delegates disconnection to the IDatabase instance.
|
|
279
189
|
*/
|
|
280
190
|
async stop() {
|
|
281
191
|
await this.plugins.stopAll();
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
try {
|
|
288
|
-
await this._lifecycleHooks.teardownDevStore();
|
|
289
|
-
}
|
|
290
|
-
catch (teardownErr) {
|
|
291
|
-
console.error('Failed to teardown dev store:', teardownErr instanceof Error
|
|
292
|
-
? teardownErr.message
|
|
293
|
-
: String(teardownErr));
|
|
294
|
-
}
|
|
192
|
+
await this._database.disconnect();
|
|
193
|
+
// Teardown dev store if it was provisioned via lifecycle hooks
|
|
194
|
+
if (this._devStoreProvisioned && this._lifecycleHooks?.teardownDevStore) {
|
|
195
|
+
try {
|
|
196
|
+
await this._lifecycleHooks.teardownDevStore();
|
|
295
197
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (this._documentStore.devDatabase) {
|
|
301
|
-
await this._documentStore.devDatabase.stop();
|
|
198
|
+
catch (teardownErr) {
|
|
199
|
+
console.error('Failed to teardown dev store:', teardownErr instanceof Error
|
|
200
|
+
? teardownErr.message
|
|
201
|
+
: String(teardownErr));
|
|
302
202
|
}
|
|
303
203
|
}
|
|
304
204
|
this._ready = false;
|
|
@@ -307,26 +207,10 @@ class BaseApplication {
|
|
|
307
207
|
* Get a collection by name via the IDatabase interface.
|
|
308
208
|
* @param name Name of the collection
|
|
309
209
|
* @returns ICollection<T> for the named collection
|
|
310
|
-
* @throws if no IDatabase was provided
|
|
311
210
|
*/
|
|
312
211
|
getCollection(name) {
|
|
313
|
-
if (!this._database) {
|
|
314
|
-
throw new suite_core_lib_1.TranslatableSuiteError(suite_core_lib_1.SuiteCoreStringKey.Admin_Error_DatabaseNotConnectedYet);
|
|
315
|
-
}
|
|
316
212
|
return this._database.collection(name);
|
|
317
213
|
}
|
|
318
|
-
/**
|
|
319
|
-
* Get a model by name, delegated to the legacy document store.
|
|
320
|
-
* @deprecated Use getCollection<T>(name) with IDatabase instead.
|
|
321
|
-
* @param modelName Name of the model
|
|
322
|
-
*/
|
|
323
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
|
-
getModel(modelName) {
|
|
325
|
-
if (!this._documentStore) {
|
|
326
|
-
throw new suite_core_lib_1.TranslatableSuiteError(suite_core_lib_1.SuiteCoreStringKey.Admin_Error_DatabaseNotConnectedYet);
|
|
327
|
-
}
|
|
328
|
-
return this._documentStore.getModel(modelName);
|
|
329
|
-
}
|
|
330
214
|
}
|
|
331
215
|
exports.BaseApplication = BaseApplication;
|
|
332
216
|
//# sourceMappingURL=application-base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-base.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-express-suite/src/application-base.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"application-base.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-express-suite/src/application-base.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AASH,oEAKyC;AACzC,+BAA4B;AAC5B,2CAA+C;AAC/C,+CAA4C;AAI5C,uCAA0C;AAC1C,mCAAmC;AAGnC;;;;;;;GAOG;AACH,MAAa,eAAe;IAK1B;;OAEG;IACK,YAAY,CAAmB;IAEvC;;OAEG;IACK,UAAU,CAAa;IAE/B;;OAEG;IACgB,SAAS,CAAY;IAExC;;OAEG;IACgB,eAAe,CAEpB;IAEd;;OAEG;IACO,oBAAoB,GAAG,KAAK,CAAC;IAEv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CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACrB,OAAO,CAAC,KAAK,CACX,+BAA+B,EAC/B,WAAW,YAAY,KAAK;oBAC1B,CAAC,CAAC,WAAW,CAAC,OAAO;oBACrB,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CACxB,CAAC;YACJ,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAyB,IAAY;QACvD,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAI,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF;AA5PD,0CA4PC"}
|
package/src/application.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Main application class with Express server.
|
|
3
|
-
* Extends
|
|
3
|
+
* Extends MongoApplicationBase with HTTP/HTTPS server and routing.
|
|
4
4
|
* @module application
|
|
5
5
|
*/
|
|
6
6
|
import mongoose from '@digitaldefiance/mongoose-types';
|
|
7
7
|
import { Application as ExpressApplication } from 'express';
|
|
8
8
|
import { HelmetOptions } from 'helmet';
|
|
9
|
-
import {
|
|
9
|
+
import { MongoApplicationBase } from './mongo-application-base';
|
|
10
10
|
import { IBaseDocument } from './documents/base';
|
|
11
11
|
import { Environment } from './environment';
|
|
12
12
|
import { IApplication, ICSPConfig, IFailableResult, IServerInitResult, IMongoApplication } from './interfaces';
|
|
@@ -18,7 +18,7 @@ import { AppRouter } from './routers/app';
|
|
|
18
18
|
import { BaseRouter } from './routers/base';
|
|
19
19
|
import { SchemaMap } from './types';
|
|
20
20
|
import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
21
|
-
export declare class Application<TInitResults extends IServerInitResult<TID>, TModelDocs extends Record<string, IBaseDocument<any, TID>>, TID extends PlatformID = Buffer, TEnvironment extends Environment<TID> = Environment<TID>, TConstants extends IConstants = IConstants, TAppRouter extends AppRouter<TID> = AppRouter<TID>> extends
|
|
21
|
+
export declare class Application<TInitResults extends IServerInitResult<TID>, TModelDocs extends Record<string, IBaseDocument<any, TID>>, TID extends PlatformID = Buffer, TEnvironment extends Environment<TID> = Environment<TID>, TConstants extends IConstants = IConstants, TAppRouter extends AppRouter<TID> = AppRouter<TID>> extends MongoApplicationBase<TID, TModelDocs, TInitResults, TConstants> implements IMongoApplication<TID> {
|
|
22
22
|
readonly expressApp: ExpressApplication;
|
|
23
23
|
private server;
|
|
24
24
|
private readonly _cspConfig;
|
|
@@ -29,7 +29,7 @@ export declare class Application<TInitResults extends IServerInitResult<TID>, TM
|
|
|
29
29
|
private greenlockManager;
|
|
30
30
|
get environment(): TEnvironment;
|
|
31
31
|
protected registerServices(): void;
|
|
32
|
-
constructor(environment: TEnvironment, apiRouterFactory: (app: IApplication<TID>) => BaseRouter<TID>, schemaMapFactory: (connection: mongoose.Connection) => SchemaMap<TID, TModelDocs>, databaseInitFunction: (application:
|
|
32
|
+
constructor(environment: TEnvironment, apiRouterFactory: (app: IApplication<TID>) => BaseRouter<TID>, schemaMapFactory: (connection: mongoose.Connection) => SchemaMap<TID, TModelDocs>, databaseInitFunction: (application: MongoApplicationBase<TID, TModelDocs, TInitResults>) => Promise<IFailableResult<TInitResults>>, initResultHashFunction: (initResults: TInitResults) => string, cspConfig?: ICSPConfig | HelmetOptions | IFlexibleCSP, constants?: TConstants, appRouterFactory?: (apiRouter: BaseRouter<TID>) => TAppRouter, customInitMiddleware?: typeof initMiddleware, documentStore?: IDocumentStore<TID, TModelDocs>);
|
|
33
33
|
start(mongoUri?: string): Promise<void>;
|
|
34
34
|
stop(): Promise<void>;
|
|
35
35
|
}
|
package/src/application.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-express-suite/src/application.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AAOvD,OAAgB,EACd,WAAW,IAAI,kBAAkB,EAIlC,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAIvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-express-suite/src/application.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AAOvD,OAAgB,EACd,WAAW,IAAI,kBAAkB,EAIlC,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAIvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,UAAU,EACV,eAAe,EAEf,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAiB,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,cAAc,EAAmB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAK5C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAOlE,qBAAa,WAAW,CACtB,YAAY,SAAS,iBAAiB,CAAC,GAAG,CAAC,EAC3C,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAC1D,GAAG,SAAS,UAAU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,EAAE,UAAU,CAAC,GAAG,CAAC,KAAK,UAEP,EAC3C,oBAAoB,GAAE,OAAO,cAA+B,EAC5D,aAAa,CAAC,EAAE,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC;IAqB3B,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqKvC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CA0C5C"}
|
package/src/application.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @fileoverview Main application class with Express server.
|
|
4
|
-
* Extends
|
|
4
|
+
* Extends MongoApplicationBase with HTTP/HTTPS server and routing.
|
|
5
5
|
* @module application
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -13,7 +13,7 @@ const express_1 = tslib_1.__importDefault(require("express"));
|
|
|
13
13
|
const fs_1 = require("fs");
|
|
14
14
|
const https_1 = require("https");
|
|
15
15
|
const path_1 = require("path");
|
|
16
|
-
const
|
|
16
|
+
const mongo_application_base_1 = require("./mongo-application-base");
|
|
17
17
|
const interfaces_1 = require("./interfaces");
|
|
18
18
|
const flexible_csp_1 = require("./interfaces/flexible-csp");
|
|
19
19
|
const middleware_utils_1 = require("./middleware-utils");
|
|
@@ -21,7 +21,7 @@ const app_1 = require("./routers/app");
|
|
|
21
21
|
const services_1 = require("./services");
|
|
22
22
|
const utils_1 = require("./utils");
|
|
23
23
|
const greenlock_manager_1 = require("./greenlock-manager");
|
|
24
|
-
class Application extends
|
|
24
|
+
class Application extends mongo_application_base_1.MongoApplicationBase {
|
|
25
25
|
expressApp;
|
|
26
26
|
server = null;
|
|
27
27
|
_cspConfig;
|