@tstdl/base 0.85.26 → 0.86.0-beta10
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/_container/decorators.d.ts +76 -0
- package/_container/decorators.js +110 -0
- package/_container/index.d.ts +10 -0
- package/_container/index.js +27 -0
- package/_container/interfaces.d.ts +16 -0
- package/_container/interfaces.js +26 -0
- package/_container/token.d.ts +18 -0
- package/_container/token.js +41 -0
- package/api/client/client.d.ts +2 -2
- package/api/client/client.js +5 -3
- package/api/server/api-controller.d.ts +2 -2
- package/api/server/api-controller.js +5 -4
- package/api/server/api-request-token.provider.js +2 -2
- package/api/server/gateway.d.ts +5 -6
- package/api/server/gateway.js +25 -12
- package/api/server/module.js +4 -4
- package/api/server/tokens.d.ts +4 -1
- package/api/server/tokens.js +8 -2
- package/application/application.d.ts +13 -10
- package/application/application.js +38 -45
- package/authentication/client/api.client.js +3 -3
- package/authentication/client/authentication.service.d.ts +4 -4
- package/authentication/client/authentication.service.js +20 -21
- package/authentication/client/http-client.middleware.d.ts +3 -5
- package/authentication/client/http-client.middleware.js +3 -12
- package/authentication/client/module.d.ts +2 -1
- package/authentication/client/module.js +15 -7
- package/authentication/client/tokens.d.ts +2 -2
- package/authentication/client/tokens.js +5 -4
- package/authentication/server/authentication-api-request-token.provider.js +2 -2
- package/authentication/server/authentication-secret-requirements.validator.js +2 -2
- package/authentication/server/authentication.service.d.ts +2 -2
- package/authentication/server/authentication.service.js +9 -9
- package/authentication/server/module.d.ts +2 -1
- package/authentication/server/module.js +8 -7
- package/authentication/server/mongo/mongo-authentication-credentials.repository.d.ts +3 -3
- package/authentication/server/mongo/mongo-authentication-credentials.repository.js +4 -4
- package/authentication/server/mongo/mongo-authentication-session.repository.d.ts +3 -3
- package/authentication/server/mongo/mongo-authentication-session.repository.js +4 -4
- package/browser/browser-context-controller.d.ts +4 -4
- package/browser/browser-context-controller.js +15 -9
- package/browser/browser-controller.d.ts +12 -5
- package/browser/browser-controller.js +24 -10
- package/browser/browser.service.d.ts +12 -6
- package/browser/browser.service.js +13 -10
- package/browser/module.js +2 -2
- package/container/decorators.d.ts +2 -76
- package/container/decorators.js +12 -88
- package/container/index.d.ts +0 -7
- package/container/index.js +0 -7
- package/container/interfaces.d.ts +2 -16
- package/container/interfaces.js +3 -4
- package/container/token.d.ts +2 -18
- package/container/token.js +4 -19
- package/core.d.ts +4 -2
- package/core.js +15 -8
- package/database/mongo/classes.d.ts +5 -5
- package/database/mongo/classes.js +5 -4
- package/database/mongo/module.js +24 -16
- package/database/mongo/mongo-entity-repository.d.ts +2 -2
- package/database/mongo/mongo-entity-repository.js +2 -2
- package/disposable/async-disposer.d.ts +4 -4
- package/distributed-loop/distributed-loop.d.ts +3 -3
- package/distributed-loop/distributed-loop.js +3 -3
- package/distributed-loop/provider.js +2 -2
- package/examples/api/authentication.js +17 -10
- package/examples/api/basic-overview.js +4 -5
- package/examples/api/custom-authentication.js +9 -6
- package/examples/api/streaming.js +5 -5
- package/examples/browser/basic.js +5 -5
- package/examples/http/client.js +6 -4
- package/examples/mail/basic.js +9 -4
- package/examples/pdf/basic.js +9 -5
- package/examples/template/basic.js +8 -6
- package/function/log.js +1 -1
- package/http/client/adapters/undici-http-client.adapter.js +7 -6
- package/http/client/http-client-options.d.ts +0 -5
- package/http/client/http-client-options.js +0 -4
- package/http/client/http-client.d.ts +5 -8
- package/http/client/http-client.js +10 -7
- package/http/client/middleware.d.ts +6 -0
- package/http/client/middleware.js +16 -0
- package/http/client/module.d.ts +6 -1
- package/http/client/module.js +10 -5
- package/http/client/tokens.d.ts +2 -0
- package/http/client/tokens.js +25 -0
- package/http/server/node/module.js +2 -2
- package/http/server/node/node-http-server.d.ts +1 -4
- package/http/server/node/node-http-server.js +3 -7
- package/image-service/imgproxy/imgproxy-image-service.d.ts +6 -8
- package/image-service/imgproxy/imgproxy-image-service.js +17 -16
- package/injector/decorators.d.ts +12 -6
- package/injector/decorators.js +14 -0
- package/injector/index.d.ts +11 -0
- package/injector/index.js +28 -0
- package/injector/inject.d.ts +6 -1
- package/injector/inject.js +14 -2
- package/injector/injector.d.ts +14 -34
- package/injector/injector.js +91 -48
- package/injector/interfaces.d.ts +7 -5
- package/injector/provider.d.ts +19 -14
- package/injector/token.d.ts +10 -3
- package/injector/token.js +1 -1
- package/injector/type-info.d.ts +2 -0
- package/injector/types.d.ts +13 -7
- package/key-value-store/key-value.store.d.ts +3 -3
- package/key-value-store/key-value.store.js +1 -1
- package/key-value-store/mongo/module.js +4 -4
- package/key-value-store/mongo/mongo-key-value-store.provider.js +2 -2
- package/key-value-store/mongo/mongo-key-value.repository.d.ts +3 -3
- package/key-value-store/mongo/mongo-key-value.repository.js +4 -4
- package/key-value-store/mongo/mongo-key-value.store.js +3 -3
- package/key-value-store/mongo/tokens.d.ts +1 -1
- package/key-value-store/mongo/tokens.js +1 -1
- package/lock/lock.d.ts +3 -2
- package/lock/lock.js +1 -0
- package/lock/mongo/lock.js +4 -4
- package/lock/mongo/module.js +3 -3
- package/lock/mongo/mongo-lock-repository.d.ts +3 -3
- package/lock/mongo/mongo-lock-repository.js +3 -3
- package/lock/mongo/provider.js +5 -5
- package/lock/provider.d.ts +3 -2
- package/lock/provider.js +1 -0
- package/lock/web/module.js +3 -3
- package/lock/web/web-lock.js +2 -2
- package/lock/web/web-lock.provider.js +3 -3
- package/logger/console/logger.js +2 -2
- package/logger/logger.d.ts +3 -2
- package/logger/logger.js +1 -0
- package/mail/clients/nodemailer.mail-client.js +6 -5
- package/mail/mail.client.d.ts +3 -2
- package/mail/mail.client.js +1 -0
- package/mail/mail.service.js +7 -7
- package/mail/module.js +5 -5
- package/mail/repositories/mongo-mail-log.repository.d.ts +3 -3
- package/mail/repositories/mongo-mail-log.repository.js +3 -3
- package/mail/tokens.d.ts +1 -1
- package/mail/tokens.js +2 -2
- package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js +3 -3
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.d.ts +1 -1
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.js +3 -3
- package/message-bus/broadcast-channel/module.js +3 -3
- package/message-bus/local/local-message-bus-provider.js +4 -4
- package/message-bus/local/local-message-bus.d.ts +1 -1
- package/message-bus/local/local-message-bus.js +3 -3
- package/message-bus/local/module.js +3 -3
- package/message-bus/message-bus.d.ts +3 -3
- package/message-bus/message-bus.js +1 -0
- package/migration/index.d.ts +1 -1
- package/migration/index.js +1 -1
- package/migration/migrator.js +4 -4
- package/migration/mongo/migration-state-repository.d.ts +3 -3
- package/migration/mongo/migration-state-repository.js +4 -4
- package/migration/mongo/module.js +2 -2
- package/module/modules/web-server.module.d.ts +5 -10
- package/module/modules/web-server.module.js +16 -36
- package/notification/notification.service.js +2 -2
- package/object-storage/object-storage.d.ts +3 -3
- package/object-storage/object-storage.js +1 -0
- package/object-storage/s3/s3.object-storage-provider.js +6 -5
- package/object-storage/s3/s3.object-storage.d.ts +2 -2
- package/object-storage/s3/s3.object-storage.js +4 -4
- package/openid-connect/cached-oidc-configuration.service.js +3 -3
- package/openid-connect/index.d.ts +1 -1
- package/openid-connect/index.js +3 -3
- package/openid-connect/mongo-oidc-state.repository.d.ts +3 -3
- package/openid-connect/mongo-oidc-state.repository.js +6 -5
- package/openid-connect/oidc-configuration.service.js +2 -2
- package/openid-connect/oidc.service.js +4 -4
- package/package.json +1 -1
- package/pdf/pdf.service.d.ts +3 -3
- package/pdf/pdf.service.js +5 -5
- package/process-shutdown.d.ts +2 -2
- package/process-shutdown.js +6 -8
- package/queue/mongo/mongo-job.repository.d.ts +3 -3
- package/queue/mongo/mongo-job.repository.js +4 -4
- package/queue/mongo/queue.js +4 -4
- package/queue/mongo/queue.provider.d.ts +3 -3
- package/queue/mongo/queue.provider.js +8 -6
- package/queue/queue.d.ts +3 -3
- package/queue/queue.js +1 -1
- package/search-index/elastic/config.d.ts +3 -3
- package/search-index/elastic/config.js +4 -3
- package/search-index/elastic/module.d.ts +1 -3
- package/search-index/elastic/module.js +21 -18
- package/search-index/elastic/search-index.d.ts +2 -2
- package/search-index/elastic/search-index.js +2 -2
- package/templates/module.d.ts +2 -2
- package/templates/module.js +12 -26
- package/templates/providers/file.template-provider.d.ts +3 -3
- package/templates/providers/file.template-provider.js +5 -4
- package/templates/providers/memory.template-provider.js +2 -2
- package/templates/renderers/handlebars.template-renderer.js +2 -2
- package/templates/renderers/jsx.template-renderer.js +2 -2
- package/templates/renderers/mjml.template-renderer.js +3 -3
- package/templates/renderers/string.template-renderer.js +2 -2
- package/templates/resolvers/file.template-resolver.d.ts +3 -3
- package/templates/resolvers/file.template-resolver.js +6 -5
- package/templates/resolvers/jsx.template-resolver.js +2 -2
- package/templates/resolvers/string.template-resolver.js +2 -2
- package/templates/template-renderer.provider.js +3 -3
- package/templates/template-resolver.provider.js +3 -3
- package/templates/template.service.js +4 -4
- package/templates/tokens.d.ts +2 -2
- package/templates/tokens.js +3 -3
- package/text/dynamic-text.model.js +3 -4
- package/text/localization.service.js +3 -3
- package/theme/theme-service.d.ts +1 -1
- package/theme/theme-service.js +7 -6
- package/tokens.d.ts +1 -1
- package/tokens.js +2 -2
- /package/{container → _container}/container.d.ts +0 -0
- /package/{container → _container}/container.js +0 -0
- /package/{container → _container}/provider.d.ts +0 -0
- /package/{container → _container}/provider.js +0 -0
- /package/{container → _container}/resolve-chain.d.ts +0 -0
- /package/{container → _container}/resolve-chain.js +0 -0
- /package/{container → _container}/resolve.error.d.ts +0 -0
- /package/{container → _container}/resolve.error.js +0 -0
- /package/{container → _container}/type-info.d.ts +0 -0
- /package/{container → _container}/type-info.js +0 -0
- /package/{container → _container}/types.d.ts +0 -0
- /package/{container → _container}/types.js +0 -0
- /package/{container → _container}/utils.d.ts +0 -0
- /package/{container → _container}/utils.js +0 -0
package/core.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { InjectionToken } from './container/index.js';
|
|
2
1
|
import { AsyncDisposer } from './disposable/async-disposer.js';
|
|
2
|
+
import { Injector } from './injector/injector.js';
|
|
3
|
+
import type { InjectionToken } from './injector/token.js';
|
|
3
4
|
import type { LoggerArgument } from './logger/index.js';
|
|
4
5
|
import { LogLevel, Logger } from './logger/index.js';
|
|
5
|
-
export declare const CORE_LOGGER: InjectionToken<Logger,
|
|
6
|
+
export declare const CORE_LOGGER: InjectionToken<Logger, never>;
|
|
7
|
+
export declare const rootInjector: Injector;
|
|
6
8
|
export declare const disposer: AsyncDisposer;
|
|
7
9
|
export declare function isDevMode(): boolean;
|
|
8
10
|
export declare function isProdMode(): boolean;
|
package/core.js
CHANGED
|
@@ -25,16 +25,20 @@ __export(core_exports, {
|
|
|
25
25
|
disposer: () => disposer,
|
|
26
26
|
enableProdMode: () => enableProdMode,
|
|
27
27
|
isDevMode: () => isDevMode,
|
|
28
|
-
isProdMode: () => isProdMode
|
|
28
|
+
isProdMode: () => isProdMode,
|
|
29
|
+
rootInjector: () => rootInjector
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(core_exports);
|
|
31
|
-
var import_container = require("./container/index.js");
|
|
32
32
|
var import_async_disposer = require("./disposable/async-disposer.js");
|
|
33
|
+
var import_injector = require("./injector/injector.js");
|
|
34
|
+
var import_token = require("./injector/token.js");
|
|
33
35
|
var import_logger = require("./logger/console/logger.js");
|
|
34
36
|
var import_logger2 = require("./logger/index.js");
|
|
37
|
+
var import_process_shutdown = require("./process-shutdown.js");
|
|
35
38
|
var import_timing = require("./utils/timing.js");
|
|
36
39
|
var import_type_guards = require("./utils/type-guards.js");
|
|
37
|
-
const CORE_LOGGER = (0,
|
|
40
|
+
const CORE_LOGGER = (0, import_token.injectionToken)("core logger");
|
|
41
|
+
const rootInjector = new import_injector.Injector("RootInjector");
|
|
38
42
|
const disposer = new import_async_disposer.AsyncDisposer();
|
|
39
43
|
let _isDevMode = true;
|
|
40
44
|
function isDevMode() {
|
|
@@ -73,12 +77,15 @@ function configureTstdl(config = {}) {
|
|
|
73
77
|
if (config.production == true) {
|
|
74
78
|
enableProdMode();
|
|
75
79
|
}
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
const logger = rootInjector.resolve(CORE_LOGGER);
|
|
81
|
+
(0, import_process_shutdown.setProcessShutdownLogger)(logger);
|
|
82
|
+
(0, import_process_shutdown.initializeSignals)();
|
|
83
|
+
import_injector.Injector.register(import_logger2.Logger, { useToken: config.logger ?? import_logger.ConsoleLogger });
|
|
84
|
+
import_injector.Injector.registerSingleton(import_logger2.LogLevel, { useFactory: (level) => (0, import_type_guards.assertDefinedPass)(level, "LogLevel argument not provided") }, { defaultArgumentProvider: () => config.logLevel ?? import_logger2.LogLevel.Trace });
|
|
78
85
|
if ((0, import_type_guards.isDefined)(config.coreLogPrefix)) {
|
|
79
86
|
coreLogPrefix = config.coreLogPrefix;
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
import_injector.Injector.register(import_logger2.Logger, { useToken: import_logger.ConsoleLogger });
|
|
90
|
+
import_injector.Injector.register(import_logger2.LogLevel, { useValue: import_logger2.LogLevel.Trace });
|
|
91
|
+
import_injector.Injector.register(CORE_LOGGER, { useToken: import_logger2.Logger, defaultArgumentProvider: () => coreLogPrefix });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type resolveArgumentType } from '../../container/index.js';
|
|
1
|
+
import { resolveArgumentType } from '../../injector/interfaces.js';
|
|
3
2
|
import type { Entity } from '../../database/index.js';
|
|
3
|
+
import type { Resolvable } from '../../injector/interfaces.js';
|
|
4
4
|
import { Db, Collection as MongoCollection, MongoClient as MongoMongoClient } from 'mongodb';
|
|
5
5
|
import type { MongoDocument } from './model/document.js';
|
|
6
6
|
import type { MongoConnection, MongoRepositoryConfig } from './types.js';
|
|
@@ -11,12 +11,12 @@ export type DatabaseArgument = string | {
|
|
|
11
11
|
database?: string;
|
|
12
12
|
};
|
|
13
13
|
export type CollectionArgument<T extends Entity<any> = Entity, TDb extends Entity<any> = T> = MongoRepositoryConfig<T, TDb>;
|
|
14
|
-
export declare class MongoClient extends MongoMongoClient implements
|
|
14
|
+
export declare class MongoClient extends MongoMongoClient implements Resolvable<MongoClientArgument> {
|
|
15
15
|
readonly [resolveArgumentType]: MongoClientArgument;
|
|
16
16
|
}
|
|
17
|
-
export declare class Database extends Db implements
|
|
17
|
+
export declare class Database extends Db implements Resolvable<DatabaseArgument> {
|
|
18
18
|
readonly [resolveArgumentType]: DatabaseArgument;
|
|
19
19
|
}
|
|
20
|
-
export declare class Collection<T extends Entity<any> = Entity, TDb extends Entity<any> = T> extends MongoCollection<MongoDocument<TDb>> implements
|
|
20
|
+
export declare class Collection<T extends Entity<any> = Entity, TDb extends Entity<any> = T> extends MongoCollection<MongoDocument<TDb>> implements Resolvable<CollectionArgument<T, TDb>> {
|
|
21
21
|
readonly [resolveArgumentType]: CollectionArgument<T, TDb>;
|
|
22
22
|
}
|
|
@@ -23,7 +23,8 @@ __export(classes_exports, {
|
|
|
23
23
|
MongoClient: () => MongoClient
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(classes_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_interfaces = require("../../injector/interfaces.js");
|
|
27
|
+
var import_decorators = require("../../injector/decorators.js");
|
|
27
28
|
var import_mongodb = require("mongodb");
|
|
28
29
|
var __decorate = function(decorators, target, key, desc) {
|
|
29
30
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -38,15 +39,15 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
38
39
|
let MongoClient = class MongoClient2 extends import_mongodb.MongoClient {
|
|
39
40
|
};
|
|
40
41
|
MongoClient = __decorate([
|
|
41
|
-
(0,
|
|
42
|
+
(0, import_decorators.ReplaceClass)(import_mongodb.MongoClient)
|
|
42
43
|
], MongoClient);
|
|
43
44
|
let Database = class Database2 extends import_mongodb.Db {
|
|
44
45
|
};
|
|
45
46
|
Database = __decorate([
|
|
46
|
-
(0,
|
|
47
|
+
(0, import_decorators.ReplaceClass)(import_mongodb.Db)
|
|
47
48
|
], Database);
|
|
48
49
|
let Collection = class Collection2 extends import_mongodb.Collection {
|
|
49
50
|
};
|
|
50
51
|
Collection = __decorate([
|
|
51
|
-
(0,
|
|
52
|
+
(0, import_decorators.ReplaceClass)(import_mongodb.Collection)
|
|
52
53
|
], Collection);
|
package/database/mongo/module.js
CHANGED
|
@@ -22,8 +22,8 @@ __export(module_exports, {
|
|
|
22
22
|
mongoModuleConfig: () => mongoModuleConfig
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(module_exports);
|
|
25
|
-
var import_container = require("../../container/index.js");
|
|
26
25
|
var import_core = require("../../core.js");
|
|
26
|
+
var import_injector = require("../../injector/injector.js");
|
|
27
27
|
var import_logger = require("../../logger/index.js");
|
|
28
28
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
29
29
|
var import_classes = require("./classes.js");
|
|
@@ -37,43 +37,51 @@ function configureMongo(config) {
|
|
|
37
37
|
mongoModuleConfig.defaultConnection = config.defaultConnection ?? mongoModuleConfig.defaultConnection;
|
|
38
38
|
mongoModuleConfig.logPrefix = config.logPrefix ?? mongoModuleConfig.logPrefix;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
useFactory
|
|
40
|
+
import_injector.Injector.registerSingleton(import_classes.MongoClient, {
|
|
41
|
+
useFactory(argument, context) {
|
|
42
42
|
(0, import_type_guards.assertDefined)(argument, "mongo connection resolve argument missing");
|
|
43
43
|
const { url, ...options } = argument;
|
|
44
44
|
const logger = context.resolve(import_logger.Logger, mongoModuleConfig.logPrefix);
|
|
45
45
|
const client = new import_classes.MongoClient(url, options);
|
|
46
46
|
client.on("fullsetup", () => logger.verbose("connection setup")).on("reconnect", () => logger.warn("reconnected")).on("timeout", () => logger.warn("connection timed out")).on("close", () => logger.verbose("connection closed"));
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
context.addDisposeHandler(async () => client.close());
|
|
48
|
+
context.context.logger = logger;
|
|
49
|
+
context.context.url = url;
|
|
49
50
|
return client;
|
|
51
|
+
},
|
|
52
|
+
async afterResolve(client, _argument, context) {
|
|
53
|
+
await (0, import_core.connect)(`mongo at ${context.url}`, async () => client.connect(), context.logger);
|
|
50
54
|
}
|
|
51
55
|
}, {
|
|
52
56
|
defaultArgumentProvider: () => mongoModuleConfig.defaultConnection,
|
|
53
57
|
argumentIdentityProvider: JSON.stringify
|
|
54
58
|
});
|
|
55
|
-
|
|
56
|
-
useFactory:
|
|
59
|
+
import_injector.Injector.registerSingleton(import_classes.Database, {
|
|
60
|
+
useFactory: (argument, context) => {
|
|
57
61
|
const connection = (0, import_type_guards.isObject)(argument) ? argument.connection : mongoModuleConfig.defaultConnection;
|
|
58
62
|
const name = ((0, import_type_guards.isString)(argument) ? argument : (0, import_type_guards.isObject)(argument) ? argument.database : void 0) ?? mongoModuleConfig.defaultDatabase;
|
|
59
|
-
const client =
|
|
63
|
+
const client = context.resolve(import_classes.MongoClient, connection);
|
|
60
64
|
return client.db(name);
|
|
61
|
-
}
|
|
65
|
+
},
|
|
66
|
+
defaultArgumentProvider: () => ({ database: mongoModuleConfig.defaultDatabase, connection: mongoModuleConfig.defaultConnection })
|
|
62
67
|
}, {
|
|
63
|
-
defaultArgumentProvider: () => ({ database: mongoModuleConfig.defaultDatabase, connection: mongoModuleConfig.defaultConnection }),
|
|
64
68
|
argumentIdentityProvider: JSON.stringify
|
|
65
69
|
});
|
|
66
|
-
|
|
67
|
-
useFactory:
|
|
70
|
+
import_injector.Injector.registerSingleton(import_classes.Collection, {
|
|
71
|
+
useFactory: (config, context) => {
|
|
68
72
|
(0, import_type_guards.assertDefined)(config, "mongo repository config resolve argument missing");
|
|
69
|
-
const database =
|
|
70
|
-
|
|
73
|
+
const database = context.resolve(import_classes.Database, config);
|
|
74
|
+
context.context.database = database;
|
|
75
|
+
return database.collection(config.collection);
|
|
76
|
+
},
|
|
77
|
+
async afterResolve(_, config, context) {
|
|
78
|
+
const existingCollections = await context.database.collections();
|
|
71
79
|
for (const collection of existingCollections) {
|
|
72
80
|
if (collection.collectionName == config.collection) {
|
|
73
|
-
return
|
|
81
|
+
return;
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
|
-
|
|
84
|
+
await context.database.createCollection(config.collection);
|
|
77
85
|
}
|
|
78
86
|
}, {
|
|
79
87
|
argumentIdentityProvider: JSON.stringify
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AfterResolve } from '../../container/index.js';
|
|
2
|
-
import { afterResolve } from '../../container/index.js';
|
|
3
1
|
import type { Entity, EntityPatch, MaybeNewEntity, Query, QueryOptions, UpdateOptions } from '../../database/index.js';
|
|
4
2
|
import { EntityRepository } from '../../database/index.js';
|
|
3
|
+
import type { AfterResolve } from '../../injector/index.js';
|
|
4
|
+
import { afterResolve } from '../../injector/index.js';
|
|
5
5
|
import type { Logger } from '../../logger/index.js';
|
|
6
6
|
import type { Collection } from './classes.js';
|
|
7
7
|
import { MongoBaseRepository } from './mongo-base.repository.js';
|
|
@@ -25,8 +25,8 @@ __export(mongo_entity_repository_exports, {
|
|
|
25
25
|
noopTransformerFunction: () => noopTransformerFunction
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(mongo_entity_repository_exports);
|
|
28
|
-
var import_container = require("../../container/index.js");
|
|
29
28
|
var import_database = require("../../database/index.js");
|
|
29
|
+
var import_injector = require("../../injector/index.js");
|
|
30
30
|
var import_equals = require("../../utils/equals.js");
|
|
31
31
|
var import_object = require("../../utils/object/object.js");
|
|
32
32
|
var import_throw = require("../../utils/throw.js");
|
|
@@ -60,7 +60,7 @@ class MongoEntityRepository extends import_database.EntityRepository {
|
|
|
60
60
|
this.baseRepository = new import_mongo_base_repository.MongoBaseRepository(collection);
|
|
61
61
|
this.transformerMappingMap = new Map((0, import_object.objectEntries)(transformer.mapping ?? {}));
|
|
62
62
|
}
|
|
63
|
-
async [
|
|
63
|
+
async [import_injector.afterResolve]() {
|
|
64
64
|
await this.initialize();
|
|
65
65
|
}
|
|
66
66
|
async initialize() {
|
|
@@ -3,10 +3,10 @@ import { CancellationToken } from '../utils/cancellation-token.js';
|
|
|
3
3
|
import type { AsyncDisposable, Disposable } from './disposable.js';
|
|
4
4
|
import { disposeAsync } from './disposable.js';
|
|
5
5
|
declare const deferrerToken: unique symbol;
|
|
6
|
-
export type
|
|
7
|
-
export type AsyncDisposeHandler =
|
|
8
|
-
export type
|
|
9
|
-
taskFunction:
|
|
6
|
+
export type AsyncDisposeTaskFunction = () => any;
|
|
7
|
+
export type AsyncDisposeHandler = AsyncDisposeTaskFunction | Disposable | AsyncDisposable;
|
|
8
|
+
export type AsyncDisposeTask = {
|
|
9
|
+
taskFunction: AsyncDisposeTaskFunction;
|
|
10
10
|
};
|
|
11
11
|
export type Deferrer = {
|
|
12
12
|
[deferrerToken]: CancellationToken;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { resolveArgumentType } from '../injector/index.js';
|
|
2
|
+
import type { Resolvable } from '../injector/interfaces.js';
|
|
3
3
|
import { LockProvider } from '../lock/index.js';
|
|
4
4
|
import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
|
|
5
5
|
import type { LoopController } from './controller.js';
|
|
6
6
|
export type LoopFunction = (controller: LoopController) => any | Promise<any>;
|
|
7
7
|
/** loop key */
|
|
8
8
|
export type DistributedLoopArgument = string;
|
|
9
|
-
export declare class DistributedLoop implements
|
|
9
|
+
export declare class DistributedLoop implements Resolvable<DistributedLoopArgument> {
|
|
10
10
|
private readonly key;
|
|
11
11
|
private readonly lockProvider;
|
|
12
12
|
readonly [resolveArgumentType]: string;
|
|
@@ -21,7 +21,7 @@ __export(distributed_loop_exports, {
|
|
|
21
21
|
DistributedLoop: () => DistributedLoop
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(distributed_loop_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_injector = require("../injector/index.js");
|
|
25
25
|
var import_lock = require("../lock/index.js");
|
|
26
26
|
var import_deferred_promise = require("../promise/deferred-promise.js");
|
|
27
27
|
var import_cancellation_token = require("../utils/cancellation-token.js");
|
|
@@ -105,7 +105,7 @@ let DistributedLoop = class DistributedLoop2 {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
DistributedLoop = __decorate([
|
|
108
|
-
(0,
|
|
109
|
-
__param(0, (0,
|
|
108
|
+
(0, import_injector.Injectable)(),
|
|
109
|
+
__param(0, (0, import_injector.InjectArg)()),
|
|
110
110
|
__metadata("design:paramtypes", [String, import_lock.LockProvider])
|
|
111
111
|
], DistributedLoop);
|
|
@@ -21,7 +21,7 @@ __export(provider_exports, {
|
|
|
21
21
|
DistributedLoopProvider: () => DistributedLoopProvider
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(provider_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_decorators = require("../injector/decorators.js");
|
|
25
25
|
var import_lock = require("../lock/index.js");
|
|
26
26
|
var import_distributed_loop = require("./distributed-loop.js");
|
|
27
27
|
var __decorate = function(decorators, target, key, desc) {
|
|
@@ -48,6 +48,6 @@ let DistributedLoopProvider = class DistributedLoopProvider2 {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
DistributedLoopProvider = __decorate([
|
|
51
|
-
(0,
|
|
51
|
+
(0, import_decorators.Singleton)(),
|
|
52
52
|
__metadata("design:paramtypes", [import_lock.LockProvider])
|
|
53
53
|
], DistributedLoopProvider);
|
|
@@ -6,14 +6,16 @@ var import_client = require("../../authentication/client/index.js");
|
|
|
6
6
|
var import_server2 = require("../../authentication/server/index.js");
|
|
7
7
|
var import_mongo_authentication_credentials_repository = require("../../authentication/server/mongo/mongo-authentication-credentials.repository.js");
|
|
8
8
|
var import_mongo_authentication_session_repository = require("../../authentication/server/mongo/mongo-authentication-session.repository.js");
|
|
9
|
-
var import_container = require("../../container/index.js");
|
|
10
9
|
var import_undici_http_client_adapter = require("../../http/client/adapters/undici-http-client.adapter.js");
|
|
11
10
|
var import_module = require("../../http/client/module.js");
|
|
12
11
|
var import_module2 = require("../../http/server/node/module.js");
|
|
12
|
+
var import_inject = require("../../injector/inject.js");
|
|
13
13
|
var import_module3 = require("../../message-bus/local/module.js");
|
|
14
14
|
var import_web_server_module = require("../../module/modules/web-server.module.js");
|
|
15
|
+
var import_configure = require("../../signals/implementation/configure.js");
|
|
15
16
|
var import_timing = require("../../utils/timing.js");
|
|
16
17
|
var import_undici = require("undici");
|
|
18
|
+
(0, import_configure.configureDefaultSignalsImplementation)();
|
|
17
19
|
(0, import_server2.configureAuthenticationServer)({
|
|
18
20
|
serviceOptions: { secret: "djp0fq23576aq" },
|
|
19
21
|
credentialsRepository: import_mongo_authentication_credentials_repository.MongoAuthenticationCredentialsRepository,
|
|
@@ -21,29 +23,34 @@ var import_undici = require("undici");
|
|
|
21
23
|
});
|
|
22
24
|
(0, import_mongo_authentication_credentials_repository.configureMongoAuthenticationCredentialsRepository)({ collection: "credentials" });
|
|
23
25
|
(0, import_mongo_authentication_session_repository.configureMongoAuthenticationSessionRepository)({ collection: "sessions" });
|
|
24
|
-
(0, import_client.configureAuthenticationClient)({
|
|
25
|
-
authenticationApiClient: import_api_client.AuthenticationApiClient
|
|
26
|
-
});
|
|
27
26
|
(0, import_module3.configureLocalMessageBus)();
|
|
28
27
|
async function serverTest() {
|
|
29
|
-
const authenticationService = await
|
|
28
|
+
const authenticationService = await (0, import_inject.injectAsync)(import_server2.AuthenticationService);
|
|
30
29
|
await authenticationService.setCredentials("foobar", "mysuperdupersecret-fvhc54w");
|
|
31
30
|
}
|
|
32
31
|
async function clientTest() {
|
|
33
|
-
|
|
34
|
-
const authenticationService = import_container.container.resolve(import_client.AuthenticationService);
|
|
32
|
+
const authenticationService = (0, import_inject.inject)(import_client.AuthenticationService);
|
|
35
33
|
authenticationService.initialize();
|
|
34
|
+
await (0, import_timing.timeout)(250);
|
|
36
35
|
const passwordCheckResult = await authenticationService.checkSecret("123456");
|
|
37
36
|
console.log({ 'password check for "123456"': passwordCheckResult });
|
|
38
37
|
await authenticationService.login("foobar", "mysuperdupersecret-fvhc54w");
|
|
39
38
|
authenticationService.token$.subscribe((token) => console.log({ token }));
|
|
40
39
|
}
|
|
40
|
+
async function test() {
|
|
41
|
+
await Promise.all([
|
|
42
|
+
serverTest(),
|
|
43
|
+
clientTest()
|
|
44
|
+
]);
|
|
45
|
+
await import_application.Application.shutdown();
|
|
46
|
+
}
|
|
41
47
|
function main() {
|
|
48
|
+
(0, import_client.configureAuthenticationClient)({
|
|
49
|
+
authenticationApiClient: import_api_client.AuthenticationApiClient
|
|
50
|
+
});
|
|
42
51
|
(0, import_module2.configureNodeHttpServer)();
|
|
43
52
|
(0, import_server.configureApiServer)({ controllers: [import_server2.AuthenticationApiController] });
|
|
44
53
|
(0, import_undici_http_client_adapter.configureUndiciHttpClientAdapter)({ dispatcher: new import_undici.Agent({ keepAliveMaxTimeout: 1 }) });
|
|
45
54
|
(0, import_module.configureHttpClient)({ baseUrl: "http://localhost:8000" });
|
|
46
|
-
import_application.Application.run(import_web_server_module.WebServerModule);
|
|
47
55
|
}
|
|
48
|
-
main
|
|
49
|
-
void serverTest().then(async () => clientTest()).catch((error) => console.error(error)).then(async () => import_application.Application.shutdown());
|
|
56
|
+
import_application.Application.run(main, test, import_web_server_module.WebServerModule);
|
|
@@ -3,10 +3,10 @@ var import_client = require("../../api/client/index.js");
|
|
|
3
3
|
var import_api = require("../../api/index.js");
|
|
4
4
|
var import_server = require("../../api/server/index.js");
|
|
5
5
|
var import_application = require("../../application/application.js");
|
|
6
|
-
var import_container = require("../../container/index.js");
|
|
7
6
|
var import_undici_http_client_adapter = require("../../http/client/adapters/undici-http-client.adapter.js");
|
|
8
7
|
var import_module = require("../../http/client/module.js");
|
|
9
8
|
var import_module2 = require("../../http/server/node/module.js");
|
|
9
|
+
var import_inject = require("../../injector/inject.js");
|
|
10
10
|
var import_web_server_module = require("../../module/modules/web-server.module.js");
|
|
11
11
|
var import_schema = require("../../schema/index.js");
|
|
12
12
|
var import_timing = require("../../utils/timing.js");
|
|
@@ -87,21 +87,20 @@ UserApi = __decorate([
|
|
|
87
87
|
], UserApi);
|
|
88
88
|
const UserApiClient = (0, import_client.compileClient)(usersApiDefinition);
|
|
89
89
|
async function clientTest() {
|
|
90
|
+
const userApiClient = (0, import_inject.inject)(UserApiClient);
|
|
90
91
|
await (0, import_timing.timeout)(250);
|
|
91
|
-
const userApiClient = import_container.container.resolve(UserApiClient);
|
|
92
92
|
const allUsers = await userApiClient.loadAll();
|
|
93
93
|
console.log(allUsers);
|
|
94
94
|
await userApiClient.delete({ id: allUsers[0].id });
|
|
95
95
|
const allUsersAfterDelete = await userApiClient.loadAll();
|
|
96
96
|
console.log(allUsersAfterDelete);
|
|
97
|
+
import_application.Application.requestShutdown();
|
|
97
98
|
}
|
|
98
99
|
async function main() {
|
|
99
100
|
(0, import_module2.configureNodeHttpServer)();
|
|
100
101
|
(0, import_server.configureApiServer)({ controllers: [UserApi] });
|
|
101
102
|
(0, import_undici_http_client_adapter.configureUndiciHttpClientAdapter)({ dispatcher: new import_undici.Agent({ keepAliveMaxTimeout: 1 }) });
|
|
102
103
|
(0, import_module.configureHttpClient)({ baseUrl: "http://localhost:8000" });
|
|
103
|
-
import_application.Application.
|
|
104
|
-
await import_application.Application.run();
|
|
104
|
+
import_application.Application.run(import_web_server_module.WebServerModule, clientTest);
|
|
105
105
|
}
|
|
106
106
|
void main();
|
|
107
|
-
void clientTest().catch((error) => console.error(error)).then(async () => (0, import_timing.timeout)(1e3)).then(async () => import_application.Application.shutdown());
|
|
@@ -8,13 +8,15 @@ var import_authentication_service = require("../../authentication/server/authent
|
|
|
8
8
|
var import_module = require("../../authentication/server/module.js");
|
|
9
9
|
var import_mongo_authentication_credentials_repository = require("../../authentication/server/mongo/mongo-authentication-credentials.repository.js");
|
|
10
10
|
var import_mongo_authentication_session_repository = require("../../authentication/server/mongo/mongo-authentication-session.repository.js");
|
|
11
|
-
var import_container = require("../../container/index.js");
|
|
12
11
|
var import_undici_http_client_adapter = require("../../http/client/adapters/undici-http-client.adapter.js");
|
|
13
12
|
var import_module2 = require("../../http/client/module.js");
|
|
14
13
|
var import_module3 = require("../../http/server/node/module.js");
|
|
14
|
+
var import_decorators = require("../../injector/decorators.js");
|
|
15
|
+
var import_inject = require("../../injector/inject.js");
|
|
15
16
|
var import_module4 = require("../../message-bus/local/module.js");
|
|
16
17
|
var import_modules = require("../../module/modules/index.js");
|
|
17
18
|
var import_schema = require("../../schema/index.js");
|
|
19
|
+
var import_configure = require("../../signals/implementation/configure.js");
|
|
18
20
|
var import_timing = require("../../utils/timing.js");
|
|
19
21
|
var import_undici = require("undici");
|
|
20
22
|
var __decorate = function(decorators, target, key, desc) {
|
|
@@ -51,7 +53,7 @@ let CustomTokenPayloadProvider = class CustomTokenPayloadProvider2 extends impor
|
|
|
51
53
|
}
|
|
52
54
|
};
|
|
53
55
|
CustomTokenPayloadProvider = __decorate([
|
|
54
|
-
(0,
|
|
56
|
+
(0, import_decorators.Singleton)()
|
|
55
57
|
], CustomTokenPayloadProvider);
|
|
56
58
|
(0, import_module.configureAuthenticationServer)({
|
|
57
59
|
serviceOptions: { secret: "djp0fq23576aq" },
|
|
@@ -67,22 +69,23 @@ const CustomAuthenticationApiClient = (0, import_client.getAuthenticationApiClie
|
|
|
67
69
|
});
|
|
68
70
|
(0, import_module4.configureLocalMessageBus)();
|
|
69
71
|
async function serverTest() {
|
|
70
|
-
const authenticationService = await
|
|
72
|
+
const authenticationService = await (0, import_inject.injectAsync)(import_authentication_service.AuthenticationService);
|
|
71
73
|
await authenticationService.setCredentials("foobar", "supersecret");
|
|
72
74
|
}
|
|
73
75
|
async function clientTest() {
|
|
76
|
+
const authenticationService = (0, import_inject.inject)(import_client.AuthenticationService);
|
|
74
77
|
await (0, import_timing.timeout)(250);
|
|
75
|
-
const authenticationService = import_container.container.resolve(import_client.AuthenticationService);
|
|
76
78
|
authenticationService.initialize();
|
|
77
79
|
await authenticationService.login("foobar", "supersecret", { deviceId: "my-device" });
|
|
78
80
|
authenticationService.token$.subscribe((token) => console.log({ token }));
|
|
81
|
+
import_application.Application.requestShutdown();
|
|
79
82
|
}
|
|
80
83
|
function main() {
|
|
84
|
+
(0, import_configure.configureDefaultSignalsImplementation)();
|
|
81
85
|
(0, import_module3.configureNodeHttpServer)();
|
|
82
86
|
(0, import_server.configureApiServer)({ controllers: [import_authentication_api_controller.AuthenticationApiController] });
|
|
83
87
|
(0, import_undici_http_client_adapter.configureUndiciHttpClientAdapter)({ dispatcher: new import_undici.Agent({ keepAliveMaxTimeout: 1 }) });
|
|
84
88
|
(0, import_module2.configureHttpClient)({ baseUrl: "http://localhost:8000" });
|
|
85
|
-
import_application.Application.run(import_modules.WebServerModule);
|
|
89
|
+
import_application.Application.run(import_modules.WebServerModule, serverTest, clientTest);
|
|
86
90
|
}
|
|
87
91
|
main();
|
|
88
|
-
void serverTest().then(async () => clientTest()).catch((error) => console.error(error)).then(async () => import_application.Application.shutdown());
|
|
@@ -3,12 +3,12 @@ var import_client = require("../../api/client/client.js");
|
|
|
3
3
|
var import_api = require("../../api/index.js");
|
|
4
4
|
var import_server = require("../../api/server/index.js");
|
|
5
5
|
var import_application = require("../../application/application.js");
|
|
6
|
-
var import_container = require("../../container/index.js");
|
|
7
6
|
var import_core = require("../../core.js");
|
|
8
7
|
var import_undici_http_client_adapter = require("../../http/client/adapters/undici-http-client.adapter.js");
|
|
9
8
|
var import_module = require("../../http/client/module.js");
|
|
10
9
|
var import_server2 = require("../../http/server/index.js");
|
|
11
10
|
var import_node = require("../../http/server/node/index.js");
|
|
11
|
+
var import_inject = require("../../injector/inject.js");
|
|
12
12
|
var import_web_server_module = require("../../module/modules/web-server.module.js");
|
|
13
13
|
var import_sse = require("../../sse/index.js");
|
|
14
14
|
var import_encoding = require("../../utils/encoding.js");
|
|
@@ -26,7 +26,8 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
26
26
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
27
27
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
(0, import_core.configureTstdl)();
|
|
30
|
+
const logger = import_core.rootInjector.resolve(import_core.CORE_LOGGER);
|
|
30
31
|
const streamingApiDefinition = (0, import_api.defineApi)({
|
|
31
32
|
resource: "streams",
|
|
32
33
|
endpoints: {
|
|
@@ -76,8 +77,8 @@ async function* counter() {
|
|
|
76
77
|
}
|
|
77
78
|
const StreamingApiClient = (0, import_client.compileClient)(streamingApiDefinition);
|
|
78
79
|
async function clientTest() {
|
|
80
|
+
const streamingApiClient = (0, import_inject.inject)(StreamingApiClient);
|
|
79
81
|
await (0, import_timing.timeout)(250);
|
|
80
|
-
const streamingApiClient = import_container.container.resolve(StreamingApiClient);
|
|
81
82
|
const response = await streamingApiClient.echo(void 0, (0, import_stream.getReadableStreamFromIterable)(counter()).pipeThrough((0, import_encoding.encodeUtf8Stream)()));
|
|
82
83
|
for await (const responseChunk of (0, import_stream.getReadableStreamIterable)(response.pipeThrough((0, import_encoding.decodeTextStream)()))) {
|
|
83
84
|
logger.info(`response: "${responseChunk}"
|
|
@@ -90,10 +91,9 @@ function main() {
|
|
|
90
91
|
(0, import_server.configureApiServer)({ controllers: [StreamingApi] });
|
|
91
92
|
(0, import_undici_http_client_adapter.configureUndiciHttpClientAdapter)({ dispatcher: new import_undici.Agent({ keepAliveMaxTimeout: 1 }) });
|
|
92
93
|
(0, import_module.configureHttpClient)({ baseUrl: "http://localhost:8000" });
|
|
93
|
-
import_application.Application.run(import_web_server_module.WebServerModule);
|
|
94
|
+
import_application.Application.run(import_web_server_module.WebServerModule, clientTest);
|
|
94
95
|
}
|
|
95
96
|
main();
|
|
96
|
-
void clientTest().catch((error) => logger.error(error));
|
|
97
97
|
function eventsSource() {
|
|
98
98
|
const events = new import_sse.ServerSentEventsSource();
|
|
99
99
|
void (async () => {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var import_promises = require("node:fs/promises");
|
|
3
3
|
var import_application = require("../../application/index.js");
|
|
4
4
|
var import_browser_service = require("../../browser/browser.service.js");
|
|
5
|
-
var
|
|
5
|
+
var import_inject = require("../../injector/inject.js");
|
|
6
6
|
var import_logger = require("../../logger/logger.js");
|
|
7
7
|
var import_timing = require("../../utils/timing.js");
|
|
8
8
|
async function main() {
|
|
9
|
-
const
|
|
9
|
+
const logger = (0, import_inject.inject)(import_logger.Logger).subModule("BROWSER");
|
|
10
|
+
const browserService = await (0, import_inject.injectAsync)(import_browser_service.BrowserService);
|
|
10
11
|
const browser = await browserService.newBrowser({ headless: false });
|
|
11
12
|
const context = await browser.newContext();
|
|
12
13
|
const page = await context.newPage();
|
|
13
|
-
const logger = import_container.container.resolve(import_logger.Logger).subModule("BROWSER");
|
|
14
14
|
page.attachLogger(logger);
|
|
15
15
|
await page.navigate("https://google.com");
|
|
16
16
|
await page.getBySelector("//div[text() = 'Alle ablehnen']").click();
|
|
17
17
|
await (0, import_timing.timeout)(1e3);
|
|
18
18
|
const pdf = await page.renderPdf();
|
|
19
|
-
(0,
|
|
19
|
+
await (0, import_promises.writeFile)("/tmp/pdf.pdf", pdf);
|
|
20
20
|
await page.navigate("file:///tmp/pdf.pdf");
|
|
21
21
|
await page.waitForClose();
|
|
22
22
|
}
|
package/examples/http/client.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var import_application = require("../../application/application.js");
|
|
3
3
|
var import_undici_http_client_adapter = require("../../http/client/adapters/undici-http-client.adapter.js");
|
|
4
4
|
var import_client = require("../../http/client/index.js");
|
|
5
|
+
var import_inject = require("../../injector/inject.js");
|
|
5
6
|
(0, import_undici_http_client_adapter.configureUndiciHttpClientAdapter)();
|
|
6
7
|
async function main() {
|
|
7
|
-
const httpClient =
|
|
8
|
+
const httpClient = (0, import_inject.inject)(import_client.HttpClient);
|
|
8
9
|
const response = await httpClient.get("https://httpbin.org/anything/:whatever", {
|
|
9
10
|
parameters: {
|
|
10
11
|
whatever: "foobar",
|
|
11
12
|
anotherParameter: "hello-world"
|
|
12
13
|
}
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
+
const body = await response.body.readAsJson();
|
|
16
|
+
console.log(response.asObject(), body);
|
|
15
17
|
}
|
|
16
|
-
|
|
18
|
+
import_application.Application.run(main);
|
package/examples/mail/basic.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var import_node_path = require("node:path");
|
|
3
3
|
var import_node_url = require("node:url");
|
|
4
|
-
var
|
|
4
|
+
var import_application = require("../../application/application.js");
|
|
5
|
+
var import_inject = require("../../injector/inject.js");
|
|
5
6
|
var import_nodemailer_mail_client = require("../../mail/clients/nodemailer.mail-client.js");
|
|
6
7
|
var import_mail = require("../../mail/index.js");
|
|
7
8
|
var import_templates = require("../../templates/index.js");
|
|
8
9
|
var import_file_template_provider = require("../../templates/providers/file.template-provider.js");
|
|
9
10
|
var import_handlebars_template_renderer = require("../../templates/renderers/handlebars.template-renderer.js");
|
|
11
|
+
var import_jsx_template_renderer = require("../../templates/renderers/jsx.template-renderer.js");
|
|
10
12
|
var import_mjml_template_renderer = require("../../templates/renderers/mjml.template-renderer.js");
|
|
13
|
+
var import_string_template_renderer = require("../../templates/renderers/string.template-renderer.js");
|
|
11
14
|
var import_file_template_resolver = require("../../templates/resolvers/file.template-resolver.js");
|
|
15
|
+
var import_string_template_resolver = require("../../templates/resolvers/string.template-resolver.js");
|
|
12
16
|
var import_config_parser = require("../../utils/config-parser.js");
|
|
13
17
|
var import_core = require("../../core.js");
|
|
14
18
|
const import_meta = {};
|
|
@@ -32,13 +36,14 @@ try {
|
|
|
32
36
|
});
|
|
33
37
|
(0, import_templates.configureTemplates)({
|
|
34
38
|
templateProvider: import_file_template_provider.FileTemplateProvider,
|
|
35
|
-
templateRenderers: [import_mjml_template_renderer.MjmlTemplateRenderer, import_handlebars_template_renderer.HandlebarsTemplateRenderer]
|
|
39
|
+
templateRenderers: [import_mjml_template_renderer.MjmlTemplateRenderer, import_handlebars_template_renderer.HandlebarsTemplateRenderer, import_jsx_template_renderer.JsxTemplateRenderer, import_string_template_renderer.StringTemplateRenderer],
|
|
40
|
+
templateResolvers: [import_string_template_resolver.StringTemplateResolver]
|
|
36
41
|
});
|
|
37
42
|
(0, import_file_template_provider.configureFileTemplateProvider)({ basePath: (0, import_node_path.resolve)(dirname, "templates") });
|
|
38
43
|
(0, import_file_template_resolver.configureFileTemplateResolver)({ basePath: (0, import_node_path.resolve)(dirname.replace("/dist", "/source"), "templates") });
|
|
39
44
|
async function test() {
|
|
40
|
-
const service = await
|
|
45
|
+
const service = await (0, import_inject.injectAsync)(import_mail.MailService);
|
|
41
46
|
const result = await service.sendTemplate("hello-name", { from: (0, import_config_parser.string)("FROM", (0, import_config_parser.string)("USER", "user@example.com")), to: (0, import_config_parser.string)("TO", "user@example.com") }, { name: "Max Mustermann" });
|
|
42
47
|
console.log(result);
|
|
43
48
|
}
|
|
44
|
-
|
|
49
|
+
import_application.Application.run(test);
|