@kurdel/runtime 0.1.0-beta.2 → 0.1.0-beta.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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { IoCContainer } from '@kurdel/ioc';
|
|
2
|
-
import {
|
|
2
|
+
import { Database, type DatabaseDialect } from '@kurdel/db';
|
|
3
3
|
import type { AppConfig, AppModule } from '@kurdel/core/app';
|
|
4
|
-
export declare class NoopDatabase implements
|
|
4
|
+
export declare class NoopDatabase implements Database {
|
|
5
|
+
get dialect(): DatabaseDialect;
|
|
5
6
|
query: () => Promise<void>;
|
|
6
7
|
get: () => Promise<void>;
|
|
7
8
|
all: () => Promise<void>;
|
|
@@ -14,7 +15,7 @@ export declare class NoopDatabase implements IDatabase {
|
|
|
14
15
|
* DatabaseModule
|
|
15
16
|
*
|
|
16
17
|
* - Provides a database connection if enabled
|
|
17
|
-
* - Exports the
|
|
18
|
+
* - Exports the Database token
|
|
18
19
|
* - Falls back to NoopDatabase when disabled
|
|
19
20
|
*/
|
|
20
21
|
export declare class DatabaseModule implements AppModule<AppConfig> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Database, DBConnector } from '@kurdel/db';
|
|
2
2
|
import { TOKENS } from '@kurdel/core/tokens';
|
|
3
3
|
export class NoopDatabase {
|
|
4
4
|
constructor() {
|
|
@@ -8,6 +8,9 @@ export class NoopDatabase {
|
|
|
8
8
|
this.run = this.error;
|
|
9
9
|
this.close = this.error;
|
|
10
10
|
}
|
|
11
|
+
get dialect() {
|
|
12
|
+
throw new Error('Database is disabled (db=false in config)');
|
|
13
|
+
}
|
|
11
14
|
async transaction() {
|
|
12
15
|
throw new Error('Database is disabled (db=false in config)');
|
|
13
16
|
}
|
|
@@ -19,21 +22,21 @@ export class NoopDatabase {
|
|
|
19
22
|
* DatabaseModule
|
|
20
23
|
*
|
|
21
24
|
* - Provides a database connection if enabled
|
|
22
|
-
* - Exports the
|
|
25
|
+
* - Exports the Database token
|
|
23
26
|
* - Falls back to NoopDatabase when disabled
|
|
24
27
|
*/
|
|
25
28
|
export class DatabaseModule {
|
|
26
29
|
constructor() {
|
|
27
|
-
this.exports = { db:
|
|
30
|
+
this.exports = { db: Database };
|
|
28
31
|
}
|
|
29
32
|
async register(ioc, config) {
|
|
30
33
|
if (config.db === false) {
|
|
31
|
-
ioc.bind(
|
|
34
|
+
ioc.bind(Database).toInstance(new NoopDatabase());
|
|
32
35
|
return;
|
|
33
36
|
}
|
|
34
37
|
const connector = new DBConnector();
|
|
35
38
|
const connection = await connector.run();
|
|
36
|
-
ioc.bind(
|
|
39
|
+
ioc.bind(Database).toInstance(connection);
|
|
37
40
|
ioc.get(TOKENS.OnShutdown).push(() => connection.close());
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-module.js","sourceRoot":"","sources":["../../src/modules/database-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"database-module.js","sourceRoot":"","sources":["../../src/modules/database-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAwB,MAAM,YAAY,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,OAAO,YAAY;IAAzB;QAIE,UAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACnB,QAAG,GAAG,IAAI,CAAC,KAAK,CAAC;QACjB,QAAG,GAAG,IAAI,CAAC,KAAK,CAAC;QACjB,QAAG,GAAG,IAAI,CAAC,KAAK,CAAC;QAIjB,UAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IAKrB,CAAC;IAfC,IAAI,OAAO;QACT,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAKD,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAGO,KAAK,CAAC,KAAK;QACjB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IAA3B;QACW,YAAO,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;IAatC,CAAC;IAXC,KAAK,CAAC,QAAQ,CAAC,GAAiB,EAAE,MAAiB;QACjD,IAAI,MAAM,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YACxB,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC;YAClD,OAAO;QACT,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,WAAW,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC;QACzC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC1C,GAAG,CAAC,GAAG,CAAmB,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -5,7 +5,7 @@ import type { ModelList } from '@kurdel/core/db';
|
|
|
5
5
|
* ModelModule
|
|
6
6
|
*
|
|
7
7
|
* - Registers models from all HttpModules
|
|
8
|
-
* - Models depend on
|
|
8
|
+
* - Models depend on Database
|
|
9
9
|
*/
|
|
10
10
|
export declare class ModelModule implements AppModule<AppConfig> {
|
|
11
11
|
private models;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Database } from '@kurdel/db';
|
|
2
2
|
/**
|
|
3
3
|
* ModelModule
|
|
4
4
|
*
|
|
5
5
|
* - Registers models from all HttpModules
|
|
6
|
-
* - Models depend on
|
|
6
|
+
* - Models depend on Database
|
|
7
7
|
*/
|
|
8
8
|
export class ModelModule {
|
|
9
9
|
constructor(models) {
|
|
10
10
|
this.models = models;
|
|
11
|
-
this.imports = { db:
|
|
11
|
+
this.imports = { db: Database };
|
|
12
12
|
}
|
|
13
13
|
async register(ioc) {
|
|
14
14
|
this.models.forEach(model => {
|
|
15
15
|
if ('use' in model) {
|
|
16
|
-
ioc.put(model.use).with({ db:
|
|
16
|
+
ioc.put(model.use).with({ db: Database, ...model.deps });
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
|
-
ioc.put(model).with({ db:
|
|
19
|
+
ioc.put(model).with({ db: Database });
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-module.js","sourceRoot":"","sources":["../../src/modules/model-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"model-module.js","sourceRoot":"","sources":["../../src/modules/model-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAGtB,YAAoB,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;QAF5B,YAAO,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;IAEI,CAAC;IAEzC,KAAK,CAAC,QAAQ,CAAC,GAAiB;QAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC1B,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;gBACnB,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YAC3D,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurdel/runtime",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"description": "Runtime composition and request orchestration for Kurdel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"tsc-alias": "^1.8.16"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@kurdel/common": "0.1.0-beta.
|
|
61
|
-
"@kurdel/core": "0.1.0-beta.
|
|
62
|
-
"@kurdel/ioc": "0.1.0-beta.
|
|
60
|
+
"@kurdel/common": "0.1.0-beta.4",
|
|
61
|
+
"@kurdel/core": "0.1.0-beta.4",
|
|
62
|
+
"@kurdel/ioc": "0.1.0-beta.4"
|
|
63
63
|
}
|
|
64
64
|
}
|