@nest-yalc-2/app 2.1.0 → 2.2.1
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 +2 -3
- package/src/app-bootstrap-base.helper.js +21 -27
- package/src/app-bootstrap-base.helper.js.map +1 -1
- package/src/app-bootstrap-base.helper.ts +2 -2
- package/src/app-bootstrap-standalone.helper.js +10 -15
- package/src/app-bootstrap-standalone.helper.js.map +1 -1
- package/src/app-bootstrap-standalone.helper.ts +2 -2
- package/src/app-bootstrap.helper.js +29 -34
- package/src/app-bootstrap.helper.js.map +1 -1
- package/src/app-bootstrap.helper.ts +2 -2
- package/src/app-config.service.js +7 -15
- package/src/app-config.service.js.map +1 -1
- package/src/app-context.module.js +7 -10
- package/src/app-context.module.js.map +1 -1
- package/src/app-context.service.js +5 -8
- package/src/app-context.service.js.map +1 -1
- package/src/app-imports.factory.d.ts +1 -1
- package/src/app-imports.factory.js +47 -51
- package/src/app-imports.factory.js.map +1 -1
- package/src/app-imports.factory.ts +2 -2
- package/src/app.events.js +2 -5
- package/src/app.events.js.map +1 -1
- package/src/app.helper.d.ts +3 -3
- package/src/app.helper.js +7 -14
- package/src/app.helper.js.map +1 -1
- package/src/app.helper.ts +3 -3
- package/src/base-app-module.helper.d.ts +1 -1
- package/src/base-app-module.helper.js +74 -83
- package/src/base-app-module.helper.js.map +1 -1
- package/src/base-app-module.helper.ts +2 -2
- package/src/base-app.controller.js +24 -27
- package/src/base-app.controller.js.map +1 -1
- package/src/base-app.interface.d.ts +1 -1
- package/src/base-app.interface.js +1 -2
- package/src/base-app.interface.ts +1 -1
- package/src/base-app.service.js +14 -17
- package/src/base-app.service.js.map +1 -1
- package/src/cls.module.js +13 -18
- package/src/cls.module.js.map +1 -1
- package/src/conf.type.d.ts +1 -1
- package/src/conf.type.js +1 -2
- package/src/conf.type.ts +1 -1
- package/src/def.const.js +10 -13
- package/src/def.const.js.map +1 -1
- package/src/global.enum.js +2 -5
- package/src/global.enum.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -1
- package/src/life-cycle-handler.service.d.ts +1 -1
- package/src/life-cycle-handler.service.js +12 -15
- package/src/life-cycle-handler.service.js.map +1 -1
- package/src/life-cycle-handler.service.ts +1 -1
- package/src/unwrap-result.interceptor.js +9 -12
- package/src/unwrap-result.interceptor.js.map +1 -1
- package/src/yalc-controller.interface.js +1 -2
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const gql_complexity_plugin_js_1 = require("@nest-yalc-2/graphql/plugins/gql-complexity.plugin.js");
|
|
21
|
-
const class_helper_1 = require("@node-yalc/utils/class.helper");
|
|
22
|
-
const apollo_1 = require("@nestjs/apollo");
|
|
23
|
-
const dotenv = tslib_1.__importStar(require("dotenv"));
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { HttpModule } from '@nestjs/axios';
|
|
3
|
+
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
4
|
+
import { wrapSchema, RenameTypes, RenameRootFields, RenameRootTypes, RenameInterfaceFields, RenameInputObjectFields, } from '@graphql-tools/wrap';
|
|
5
|
+
import { AppContextModule } from './app-context.module.js';
|
|
6
|
+
import { AppContextService } from './app-context.service.js';
|
|
7
|
+
import { getConfNameByConnection } from '@nest-yalc-2/database/conn.helper.js';
|
|
8
|
+
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
9
|
+
import { GraphQLModule } from '@nestjs/graphql';
|
|
10
|
+
import { JwtModule } from '@nestjs/jwt';
|
|
11
|
+
import { EventEmitter2, EventEmitterModule } from '@nestjs/event-emitter';
|
|
12
|
+
import { GraphQLError } from 'graphql/error';
|
|
13
|
+
import { TypeORMLogger } from '@nest-yalc-2/logger/typeorm-logger.js';
|
|
14
|
+
import { CURAPP_CONF_ALIAS } from './def.const.js';
|
|
15
|
+
import { AppEvents } from './app.events.js';
|
|
16
|
+
import { GqlComplexityPlugin } from '@nest-yalc-2/graphql/plugins/gql-complexity.plugin.js';
|
|
17
|
+
import { isClass } from '@node-yalc/utils/class.helper.js';
|
|
18
|
+
import { ApolloFederationDriver, } from '@nestjs/apollo';
|
|
19
|
+
import * as dotenv from 'dotenv';
|
|
24
20
|
dotenv.config();
|
|
25
|
-
function AppDependencyFactory(_context, confs, dbConnNames, gqlModules, options) {
|
|
21
|
+
export function AppDependencyFactory(_context, confs, dbConnNames, gqlModules, options) {
|
|
26
22
|
const { setupEvents = true, setupJwt = true, keepDBConnectionAlive = false, buildSchemaOptions = {}, disablePlayground = false, } = options ?? {};
|
|
27
23
|
const envPath = [];
|
|
28
24
|
if (!options?.envPath) {
|
|
@@ -38,23 +34,23 @@ function AppDependencyFactory(_context, confs, dbConnNames, gqlModules, options)
|
|
|
38
34
|
}
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
const configModule =
|
|
37
|
+
Logger.debug?.(`Using ${envPath}, for environment: ${process.env.NODE_ENV}`);
|
|
38
|
+
const configModule = ConfigModule.forRoot({
|
|
43
39
|
load: confs,
|
|
44
40
|
envFilePath: envPath,
|
|
45
41
|
});
|
|
46
42
|
const imports = [
|
|
47
43
|
configModule,
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
AppContextModule,
|
|
45
|
+
HttpModule,
|
|
50
46
|
];
|
|
51
47
|
if (dbConnNames.length) {
|
|
52
48
|
dbConnNames.forEach((connName) => {
|
|
53
|
-
imports.push(
|
|
54
|
-
inject: [
|
|
49
|
+
imports.push(TypeOrmModule.forRootAsync({
|
|
50
|
+
inject: [ConfigService, TypeORMLogger],
|
|
55
51
|
name: connName,
|
|
56
52
|
useFactory: async (configService, logger) => {
|
|
57
|
-
const conf = configService.get(
|
|
53
|
+
const conf = configService.get(getConfNameByConnection(connName));
|
|
58
54
|
logger.log?.('log', `Connecting DB ${connName} to host: ${conf?.host}`);
|
|
59
55
|
return {
|
|
60
56
|
...conf,
|
|
@@ -85,11 +81,11 @@ function AppDependencyFactory(_context, confs, dbConnNames, gqlModules, options)
|
|
|
85
81
|
}
|
|
86
82
|
}
|
|
87
83
|
if (gqlModules.length) {
|
|
88
|
-
imports.push(
|
|
89
|
-
driver:
|
|
84
|
+
imports.push(GraphQLModule.forRootAsync({
|
|
85
|
+
driver: ApolloFederationDriver,
|
|
90
86
|
imports: [ApolloPluginsModule.forRoot()],
|
|
91
87
|
useFactory: async (configService, appContext, eventEmitter, gqlPluginList) => {
|
|
92
|
-
const conf = configService.get(
|
|
88
|
+
const conf = configService.get(CURAPP_CONF_ALIAS);
|
|
93
89
|
return {
|
|
94
90
|
autoSchemaFile: true,
|
|
95
91
|
buildSchemaOptions,
|
|
@@ -100,18 +96,18 @@ function AppDependencyFactory(_context, confs, dbConnNames, gqlModules, options)
|
|
|
100
96
|
const rename = (name) => {
|
|
101
97
|
if (!opPrefix || name.startsWith('_'))
|
|
102
98
|
return name;
|
|
103
|
-
if (options?.buildSchemaOptions?.orphanedTypes?.some((cl) =>
|
|
99
|
+
if (options?.buildSchemaOptions?.orphanedTypes?.some((cl) => isClass(cl) && cl.name === name))
|
|
104
100
|
return name;
|
|
105
101
|
return `${opPrefix}_${name}`;
|
|
106
102
|
};
|
|
107
|
-
const transformed =
|
|
103
|
+
const transformed = wrapSchema({
|
|
108
104
|
schema: graphQLSchema,
|
|
109
105
|
transforms: [
|
|
110
|
-
new
|
|
111
|
-
new
|
|
112
|
-
new
|
|
113
|
-
new
|
|
114
|
-
new
|
|
106
|
+
new RenameInputObjectFields((_, name) => rename(name)),
|
|
107
|
+
new RenameInterfaceFields((_, name) => rename(name)),
|
|
108
|
+
new RenameRootTypes((name) => rename(name)),
|
|
109
|
+
new RenameTypes((name) => rename(name)),
|
|
110
|
+
new RenameRootFields((_operationName, name) => rename(name)),
|
|
115
111
|
],
|
|
116
112
|
});
|
|
117
113
|
appContext.setSchema(transformed);
|
|
@@ -120,7 +116,7 @@ function AppDependencyFactory(_context, confs, dbConnNames, gqlModules, options)
|
|
|
120
116
|
include: gqlModules,
|
|
121
117
|
useGlobalPrefix: true,
|
|
122
118
|
formatError: (formattedError, error) => {
|
|
123
|
-
const graphQLError = error instanceof
|
|
119
|
+
const graphQLError = error instanceof GraphQLError ? error : undefined;
|
|
124
120
|
const exception = graphQLError?.extensions?.exception;
|
|
125
121
|
const message = exception?.response?.message ||
|
|
126
122
|
graphQLError?.message ||
|
|
@@ -149,37 +145,37 @@ function AppDependencyFactory(_context, confs, dbConnNames, gqlModules, options)
|
|
|
149
145
|
: false,
|
|
150
146
|
debug: conf?.isDev,
|
|
151
147
|
context: async ({ request, reply, ...rest }) => {
|
|
152
|
-
await eventEmitter.emitAsync(
|
|
148
|
+
await eventEmitter.emitAsync(AppEvents.BEFORE_GQL_CONTEXT_MIDDLEWARE, request, reply);
|
|
153
149
|
return {
|
|
154
150
|
request,
|
|
155
151
|
response: reply,
|
|
156
152
|
...rest,
|
|
157
153
|
};
|
|
158
154
|
},
|
|
159
|
-
plugins: [new
|
|
155
|
+
plugins: [new GqlComplexityPlugin(), ...gqlPluginList],
|
|
160
156
|
};
|
|
161
157
|
},
|
|
162
158
|
inject: [
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
ConfigService,
|
|
160
|
+
AppContextService,
|
|
161
|
+
EventEmitter2,
|
|
166
162
|
'APOLLO_PLUGINS',
|
|
167
163
|
],
|
|
168
164
|
}));
|
|
169
165
|
}
|
|
170
166
|
if (setupEvents) {
|
|
171
|
-
imports.push(
|
|
167
|
+
imports.push(EventEmitterModule.forRoot());
|
|
172
168
|
}
|
|
173
169
|
if (setupJwt) {
|
|
174
|
-
imports.push(
|
|
170
|
+
imports.push(JwtModule.registerAsync({
|
|
175
171
|
imports: [configModule],
|
|
176
172
|
useFactory: async (configService) => ({
|
|
177
|
-
secret: configService.get(
|
|
173
|
+
secret: configService.get(CURAPP_CONF_ALIAS)?.jwtSecretPrivate,
|
|
178
174
|
signOptions: {
|
|
179
175
|
expiresIn: 3600,
|
|
180
176
|
},
|
|
181
177
|
}),
|
|
182
|
-
inject: [
|
|
178
|
+
inject: [ConfigService],
|
|
183
179
|
}));
|
|
184
180
|
}
|
|
185
181
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-imports.factory.js","sourceRoot":"","sources":["app-imports.factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-imports.factory.js","sourceRoot":"","sources":["app-imports.factory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAA4B,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EACL,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAsB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,uCA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AAC;YACvB,UAAU,EAAE,KAAK,EAAE,aAA4B,EAAE,EAAE,CAAC,CAAC;gBACnD,MAAM,EAAE,aAAa,CAAC,GAAG,CAAM,iBAAiB,CAAC,EAAE,gBAAgB;gBACnE,WAAW,EAAE;oBACX,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;YACF,MAAM,EAAE,CAAC,aAAa,CAAC;SACxB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO;QACP,SAAS;QACT,OAAO,EAAE,EAAE;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -29,8 +29,8 @@ import { TypeORMLogger } from '@nest-yalc-2/logger/typeorm-logger.js';
|
|
|
29
29
|
import { CURAPP_CONF_ALIAS } from './def.const.js';
|
|
30
30
|
import { AppEvents } from './app.events.js';
|
|
31
31
|
import { GqlComplexityPlugin } from '@nest-yalc-2/graphql/plugins/gql-complexity.plugin.js';
|
|
32
|
-
import { ClassType } from '@node-yalc/types/globals';
|
|
33
|
-
import { isClass } from '@node-yalc/utils/class.helper';
|
|
32
|
+
import { ClassType } from '@node-yalc/types/globals.js';
|
|
33
|
+
import { isClass } from '@node-yalc/utils/class.helper.js';
|
|
34
34
|
import {
|
|
35
35
|
ApolloFederationDriver,
|
|
36
36
|
ApolloFederationDriverConfig,
|
package/src/app.events.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppEvents = void 0;
|
|
4
|
-
var AppEvents;
|
|
1
|
+
export var AppEvents;
|
|
5
2
|
(function (AppEvents) {
|
|
6
3
|
AppEvents["BEFORE_ALL_ROUTES"] = "app.before_all_routes";
|
|
7
4
|
AppEvents["AFTER_ALL_ROUTES"] = "app.after_all_routes";
|
|
8
5
|
AppEvents["BEFORE_GQL_CONTEXT_MIDDLEWARE"] = "app.before_gql_context_middleware";
|
|
9
|
-
})(AppEvents || (
|
|
6
|
+
})(AppEvents || (AppEvents = {}));
|
|
10
7
|
//# sourceMappingURL=app.events.js.map
|
package/src/app.events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.events.js","sourceRoot":"","sources":["app.events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.events.js","sourceRoot":"","sources":["app.events.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wDAA2C,CAAA;IAC3C,sDAAyC,CAAA;IACzC,gFAAmE,CAAA;AACrE,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB"}
|
package/src/app.helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClassType } from '@node-yalc/types/globals';
|
|
1
|
+
import { ClassType } from '@node-yalc/types/globals.js';
|
|
2
2
|
import { DynamicModule, Type } from '@nestjs/common';
|
|
3
3
|
import { BaseAppBootstrap, IGlobalOptions } from './app-bootstrap-base.helper.js';
|
|
4
4
|
export declare function isDynamicModule(module: any): module is DynamicModule;
|
|
@@ -7,9 +7,9 @@ export declare const executeFunctionForApp: (app: BaseAppBootstrap<any>, service
|
|
|
7
7
|
}, options: {
|
|
8
8
|
closeApp?: boolean;
|
|
9
9
|
}) => Promise<void>;
|
|
10
|
-
export declare const curriedExecuteStandaloneFunction: <TOptions extends IGlobalOptions>(module: any, options?: TOptions) => Promise<
|
|
10
|
+
export declare const curriedExecuteStandaloneFunction: <TOptions extends IGlobalOptions>(module: any, options?: TOptions) => Promise<(serviceType: any, fn: (service: any) => Promise<any>, executeOptions?: {
|
|
11
11
|
closeApp?: boolean;
|
|
12
|
-
}
|
|
12
|
+
}) => Promise<void>>;
|
|
13
13
|
export declare const executeStandaloneFunction: <TService, TOptions extends IGlobalOptions>(module: DynamicModule | Type<any>, serviceType: ClassType<TService>, fn: {
|
|
14
14
|
(service: TService): Promise<any>;
|
|
15
15
|
}, options?: TOptions, executeOptions?: {
|
package/src/app.helper.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.isDynamicModule = isDynamicModule;
|
|
5
|
-
const app_bootstrap_standalone_helper_js_1 = require("./app-bootstrap-standalone.helper.js");
|
|
6
|
-
const lodash_es_1 = require("lodash-es");
|
|
7
|
-
function isDynamicModule(module) {
|
|
1
|
+
import { StandaloneAppBootstrap } from './app-bootstrap-standalone.helper.js';
|
|
2
|
+
import { curry } from 'lodash-es';
|
|
3
|
+
export function isDynamicModule(module) {
|
|
8
4
|
return module.module !== undefined;
|
|
9
5
|
}
|
|
10
|
-
const executeFunctionForApp = async (app, serviceType, fn, options) => {
|
|
6
|
+
export const executeFunctionForApp = async (app, serviceType, fn, options) => {
|
|
11
7
|
const nestApp = await app.getApp();
|
|
12
8
|
await nestApp.init();
|
|
13
9
|
const service = await nestApp.resolve(serviceType);
|
|
@@ -16,11 +12,8 @@ const executeFunctionForApp = async (app, serviceType, fn, options) => {
|
|
|
16
12
|
await app.closeApp();
|
|
17
13
|
});
|
|
18
14
|
};
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const executeStandaloneFunction = async (module, serviceType, fn, options, executeOptions = {}) => {
|
|
23
|
-
return (await (0, exports.curriedExecuteStandaloneFunction)(module, options))(serviceType, fn, executeOptions);
|
|
15
|
+
export const curriedExecuteStandaloneFunction = async (module, options) => curry(executeFunctionForApp)(await new StandaloneAppBootstrap(isDynamicModule(module) ? module.module.name : module.name, module, options).initApp());
|
|
16
|
+
export const executeStandaloneFunction = async (module, serviceType, fn, options, executeOptions = {}) => {
|
|
17
|
+
return (await curriedExecuteStandaloneFunction(module, options))(serviceType, fn, executeOptions);
|
|
24
18
|
};
|
|
25
|
-
exports.executeStandaloneFunction = executeStandaloneFunction;
|
|
26
19
|
//# sourceMappingURL=app.helper.js.map
|
package/src/app.helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.helper.js","sourceRoot":"","sources":["app.helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.helper.js","sourceRoot":"","sources":["app.helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAMlC,MAAM,UAAU,eAAe,CAAC,MAAW;IACzC,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC;AACrC,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,GAA0B,EAC1B,WAAgB,EAChB,EAAoC,EACpC,OAA+B,EAChB,EAAE;IACjB,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;IACnC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IAErB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAEnD,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;QACnC,IAAI,OAAO,CAAC,QAAQ;YAAE,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AASF,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,EAGnD,MAAW,EACX,OAAkB,EACyG,EAAE,CAC7H,KAAK,CAAC,qBAAqB,CAAC,CAC1B,MAAM,IAAI,sBAAsB,CAC9B,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAC1D,MAAM,EACN,OAAO,CACR,CAAC,OAAO,EAAE,CACL,CAAC;AASX,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAI5C,MAAiC,EACjC,WAAgC,EAChC,EAAyC,EACzC,OAAkB,EAClB,iBAAyC,EAAE,EAC3C,EAAE;IACF,OAAO,CAAC,MAAM,gCAAgC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAC9D,WAAW,EACX,EAAE,EACF,cAAc,CACf,CAAC;AACJ,CAAC,CAAC"}
|
package/src/app.helper.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClassType } from '@node-yalc/types/globals';
|
|
1
|
+
import { ClassType } from '@node-yalc/types/globals.js';
|
|
2
2
|
import { DynamicModule, Type } from '@nestjs/common';
|
|
3
3
|
import { StandaloneAppBootstrap } from './app-bootstrap-standalone.helper.js';
|
|
4
4
|
import { curry } from 'lodash-es';
|
|
@@ -39,14 +39,14 @@ export const curriedExecuteStandaloneFunction = async <
|
|
|
39
39
|
>(
|
|
40
40
|
module: any,
|
|
41
41
|
options?: TOptions,
|
|
42
|
-
) =>
|
|
42
|
+
): Promise<(serviceType: any, fn: (service: any) => Promise<any>, executeOptions?: { closeApp?: boolean }) => Promise<void>> =>
|
|
43
43
|
curry(executeFunctionForApp)(
|
|
44
44
|
await new StandaloneAppBootstrap(
|
|
45
45
|
isDynamicModule(module) ? module.module.name : module.name,
|
|
46
46
|
module,
|
|
47
47
|
options,
|
|
48
48
|
).initApp(),
|
|
49
|
-
);
|
|
49
|
+
) as any;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
*
|
|
@@ -4,7 +4,7 @@ import { IGlobalOptions } from './app-bootstrap-base.helper.js';
|
|
|
4
4
|
export declare function registerSingletonDynamicModule(isSingleton: boolean, moduleToken: any, module: any): any | true;
|
|
5
5
|
export declare function getCachedModule(module: any, isSingleton: boolean): any;
|
|
6
6
|
export declare function envFilePathList(dirname?: string): string[];
|
|
7
|
-
export declare const buildEnvFilePath: (
|
|
7
|
+
export declare const buildEnvFilePath: (envDir?: string, envPath?: string | string[]) => string[];
|
|
8
8
|
export declare function yalcBaseAppModuleMetadataFactory(module: any, appAlias: string, options?: Omit<IYalcBaseAppOptions, 'module'>): IYalcBaseStaticModule;
|
|
9
9
|
export declare class YalcBaseAppModule {
|
|
10
10
|
protected static _forRootStandalone(appAlias: string, options?: IYalcBaseAppOptions): IYalcBaseDynamicModule;
|