@tsed/common 6.87.0 → 6.88.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/lib/builder/PlatformBuilder.d.ts +0 -1
- package/lib/decorators/index.d.ts +1 -0
- package/lib/decorators/method/view.d.ts +25 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +142 -117
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +143 -111
- package/lib/index.modern.js.map +1 -1
- package/lib/services/PlatformRequest.d.ts +2 -1
- package/lib/services/PlatformResponse.d.ts +4 -4
- package/lib/services/PlatformTest.d.ts +1 -1
- package/lib/utils/createInjector.d.ts +7 -2
- package/lib/utils/index.d.ts +0 -1
- package/package.json +15 -15
- package/lib/utils/createPlatformApplication.d.ts +0 -2
package/lib/index.modern.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $log, colorize } from '@tsed/logger';
|
|
2
2
|
export { $log, Logger } from '@tsed/logger';
|
|
3
3
|
import '@tsed/logger-file';
|
|
4
|
-
import { DIConfiguration, Injectable, ProviderScope, Inject, InjectorService, Constant, Provider, ProviderType, GlobalProviders, Scope, DIContext,
|
|
4
|
+
import { DIConfiguration, Injectable, ProviderScope, Inject, InjectorService, Constant, Provider, ProviderType, GlobalProviders, Scope, DIContext, registerProvider, Configuration, setLoggerLevel, createContainer, colors, DITest } from '@tsed/di';
|
|
5
5
|
export * from '@tsed/di';
|
|
6
6
|
import { ParamTypes, PlatformParams, Context, UseParam, mapParamsOptions } from '@tsed/platform-params';
|
|
7
7
|
export * from '@tsed/platform-params';
|
|
@@ -11,19 +11,17 @@ export * from '@tsed/platform-response-filter';
|
|
|
11
11
|
export * from '@tsed/platform-cache';
|
|
12
12
|
import { Middleware, getMiddlewaresForHook } from '@tsed/platform-middlewares';
|
|
13
13
|
export * from '@tsed/platform-middlewares';
|
|
14
|
-
import { PlatformViews } from '@tsed/platform-views';
|
|
15
|
-
export * from '@tsed/platform-views';
|
|
16
14
|
import { importProviders } from '@tsed/components-scan';
|
|
17
15
|
export * from '@tsed/components-scan';
|
|
18
16
|
export * from '@tsed/platform-log-middleware';
|
|
19
17
|
import { __decorate, __metadata, __param } from 'tslib';
|
|
20
|
-
import { AnyToPromise, AnyToPromiseStatus, nameOf, Store, descriptorOf, prototypeOf, deepMerge, isFunction, DecoratorTypes, isStream, uniq, isBoolean, isNumber, isString, getValue, Env,
|
|
18
|
+
import { AnyToPromise, AnyToPromiseStatus, nameOf, Store, descriptorOf, prototypeOf, deepMerge, isFunction, DecoratorTypes, isStream, uniq, isBoolean, isNumber, isString, toMap, getValue, Env, StoreMerge, Metadata, useDecorators, useMethodDecorators, StoreSet, isClass } from '@tsed/core';
|
|
21
19
|
import { Exception, NotAcceptable } from '@tsed/exceptions';
|
|
22
20
|
import { JsonParameterStore, JsonMethodStore, JsonEntityStore, JsonEntityComponent, getOperationsRoutes, OperationMethods, JsonOperationRoute, JsonPropertyStore, getProperties, concatPath, Returns, Consumes, Produces, JsonEntityFn } from '@tsed/schema';
|
|
23
21
|
export { All, Delete, Get, Head, Location, Options, Patch, Post, Put, Redirect } from '@tsed/schema';
|
|
24
22
|
import { promisify } from 'util';
|
|
25
|
-
import Http, { ServerResponse, IncomingMessage } from 'http';
|
|
26
23
|
import Https from 'https';
|
|
24
|
+
import Http, { ServerResponse, IncomingMessage } from 'http';
|
|
27
25
|
|
|
28
26
|
function _extends() {
|
|
29
27
|
_extends = Object.assign || function (target) {
|
|
@@ -1480,7 +1478,8 @@ function buildRouter(injector, provider) {
|
|
|
1480
1478
|
let PlatformRequest = class PlatformRequest {
|
|
1481
1479
|
constructor({
|
|
1482
1480
|
request
|
|
1483
|
-
}) {
|
|
1481
|
+
}, $ctx) {
|
|
1482
|
+
this.$ctx = $ctx;
|
|
1484
1483
|
this.raw = request;
|
|
1485
1484
|
}
|
|
1486
1485
|
|
|
@@ -1611,7 +1610,9 @@ let PlatformRequest = class PlatformRequest {
|
|
|
1611
1610
|
// @ts-ignore
|
|
1612
1611
|
delete this.raw; // @ts-ignore
|
|
1613
1612
|
|
|
1614
|
-
delete this.response;
|
|
1613
|
+
delete this.response; // @ts-ignore
|
|
1614
|
+
|
|
1615
|
+
delete this.$ctx;
|
|
1615
1616
|
}
|
|
1616
1617
|
/**
|
|
1617
1618
|
* Return the Framework response object (express, koa, etc...)
|
|
@@ -1631,7 +1632,7 @@ let PlatformRequest = class PlatformRequest {
|
|
|
1631
1632
|
}
|
|
1632
1633
|
|
|
1633
1634
|
};
|
|
1634
|
-
PlatformRequest = __decorate([Injectable(), Scope(ProviderScope.INSTANCE), __metadata("design:paramtypes", [Object])], PlatformRequest);
|
|
1635
|
+
PlatformRequest = __decorate([Injectable(), Scope(ProviderScope.INSTANCE), __metadata("design:paramtypes", [Object, Function])], PlatformRequest);
|
|
1635
1636
|
|
|
1636
1637
|
var PlatformResponse_1;
|
|
1637
1638
|
|
|
@@ -1645,7 +1646,8 @@ const onFinished = require("on-finished");
|
|
|
1645
1646
|
let PlatformResponse = PlatformResponse_1 = class PlatformResponse {
|
|
1646
1647
|
constructor({
|
|
1647
1648
|
response
|
|
1648
|
-
}) {
|
|
1649
|
+
}, $ctx) {
|
|
1650
|
+
this.$ctx = $ctx;
|
|
1649
1651
|
this.raw = response;
|
|
1650
1652
|
}
|
|
1651
1653
|
/**
|
|
@@ -1862,7 +1864,11 @@ let PlatformResponse = PlatformResponse_1 = class PlatformResponse {
|
|
|
1862
1864
|
|
|
1863
1865
|
|
|
1864
1866
|
async render(path, options = {}) {
|
|
1865
|
-
|
|
1867
|
+
const {
|
|
1868
|
+
PlatformViews
|
|
1869
|
+
} = await import('@tsed/platform-views');
|
|
1870
|
+
const platformViews = await this.$ctx.injector.lazyInvoke(PlatformViews);
|
|
1871
|
+
return platformViews.render(path, _extends({}, this.locals, options));
|
|
1866
1872
|
}
|
|
1867
1873
|
/**
|
|
1868
1874
|
* Send any data to your consumer.
|
|
@@ -1934,7 +1940,9 @@ let PlatformResponse = PlatformResponse_1 = class PlatformResponse {
|
|
|
1934
1940
|
delete this.raw;
|
|
1935
1941
|
delete this.data; // @ts-ignore
|
|
1936
1942
|
|
|
1937
|
-
delete this.request;
|
|
1943
|
+
delete this.request; // @ts-ignore
|
|
1944
|
+
|
|
1945
|
+
delete this.$ctx;
|
|
1938
1946
|
}
|
|
1939
1947
|
|
|
1940
1948
|
isHeadersSent() {
|
|
@@ -1942,7 +1950,7 @@ let PlatformResponse = PlatformResponse_1 = class PlatformResponse {
|
|
|
1942
1950
|
}
|
|
1943
1951
|
|
|
1944
1952
|
};
|
|
1945
|
-
PlatformResponse = PlatformResponse_1 = __decorate([Injectable(), Scope(ProviderScope.INSTANCE), __metadata("design:paramtypes", [Object])], PlatformResponse);
|
|
1953
|
+
PlatformResponse = PlatformResponse_1 = __decorate([Injectable(), Scope(ProviderScope.INSTANCE), __metadata("design:paramtypes", [Object, Function])], PlatformResponse);
|
|
1946
1954
|
|
|
1947
1955
|
const _excluded$2 = ["event", "endpoint", "ignoreUrlPatterns", "ResponseKlass", "RequestKlass"];
|
|
1948
1956
|
class PlatformContext extends DIContext {
|
|
@@ -1964,8 +1972,8 @@ class PlatformContext extends DIContext {
|
|
|
1964
1972
|
this.ignoreUrlPatterns = [];
|
|
1965
1973
|
endpoint && (this.endpoint = endpoint);
|
|
1966
1974
|
this.ignoreUrlPatterns = ignoreUrlPatterns.map(pattern => typeof pattern === "string" ? new RegExp(pattern, "gi") : pattern);
|
|
1967
|
-
this.response = new ResponseKlass(event);
|
|
1968
|
-
this.request = new RequestKlass(event);
|
|
1975
|
+
this.response = new ResponseKlass(event, this);
|
|
1976
|
+
this.request = new RequestKlass(event, this);
|
|
1969
1977
|
this.response.request = this.request;
|
|
1970
1978
|
this.request.response = this.response;
|
|
1971
1979
|
this.request.request.$ctx = this;
|
|
@@ -2206,42 +2214,21 @@ Platform = __decorate([Injectable({
|
|
|
2206
2214
|
imports: [PlatformMiddlewaresChain]
|
|
2207
2215
|
}), __metadata("design:paramtypes", [InjectorService, PlatformApplication])], Platform);
|
|
2208
2216
|
|
|
2209
|
-
$log.name = "TSED";
|
|
2210
|
-
function createInjector(settings = {}) {
|
|
2211
|
-
const injector = new InjectorService();
|
|
2212
|
-
injector.settings = createSettingsService(injector);
|
|
2213
|
-
injector.logger = $log;
|
|
2214
|
-
injector.settings.set(settings);
|
|
2215
|
-
setLoggerLevel(injector);
|
|
2216
|
-
return injector;
|
|
2217
|
-
}
|
|
2218
|
-
|
|
2219
|
-
function createSettingsService(injector) {
|
|
2220
|
-
const provider = GlobalProviders.get(PlatformConfiguration).clone();
|
|
2221
|
-
provider.instance = injector.invoke(provider.useClass);
|
|
2222
|
-
injector.addProvider(PlatformConfiguration, provider);
|
|
2223
|
-
return provider.instance;
|
|
2224
|
-
}
|
|
2225
|
-
|
|
2226
|
-
function createPlatformApplication(injector) {
|
|
2227
|
-
injector.forkProvider(PlatformApplication);
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
2217
|
/**
|
|
2231
|
-
* Inject the
|
|
2218
|
+
* Inject the Https.Server instance.
|
|
2232
2219
|
*
|
|
2233
2220
|
* ### Example
|
|
2234
2221
|
*
|
|
2235
2222
|
* ```typescript
|
|
2236
|
-
* import {
|
|
2223
|
+
* import {HttpsServer, Service} from "@tsed/common";
|
|
2237
2224
|
*
|
|
2238
2225
|
* @Service()
|
|
2239
2226
|
* export default class OtherService {
|
|
2240
|
-
* constructor(@
|
|
2227
|
+
* constructor(@HttpsServer httpServer: HttpServer) {}
|
|
2241
2228
|
* }
|
|
2242
2229
|
* ```
|
|
2243
2230
|
*
|
|
2244
|
-
* > Note: TypeScript transform and store `
|
|
2231
|
+
* > Note: TypeScript transform and store `HttpsServer` as `Function` type in the metadata. So to inject a factory, you must use the `@Inject(type)` decorator.
|
|
2245
2232
|
*
|
|
2246
2233
|
* @param {Type<any>} target
|
|
2247
2234
|
* @param {string} targetKey
|
|
@@ -2250,8 +2237,8 @@ function createPlatformApplication(injector) {
|
|
|
2250
2237
|
* @decorator
|
|
2251
2238
|
*/
|
|
2252
2239
|
|
|
2253
|
-
function
|
|
2254
|
-
return Inject(
|
|
2240
|
+
function HttpsServer(target, targetKey, descriptor) {
|
|
2241
|
+
return Inject(HttpsServer)(target, targetKey, descriptor);
|
|
2255
2242
|
}
|
|
2256
2243
|
|
|
2257
2244
|
function listenServer(http, settings) {
|
|
@@ -2273,56 +2260,57 @@ function listenServer(http, settings) {
|
|
|
2273
2260
|
return promise;
|
|
2274
2261
|
}
|
|
2275
2262
|
|
|
2276
|
-
function
|
|
2277
|
-
injector.
|
|
2263
|
+
function createHttpsServer(injector) {
|
|
2264
|
+
injector.invoke(HttpsServer);
|
|
2278
2265
|
}
|
|
2279
2266
|
registerProvider({
|
|
2280
|
-
provide:
|
|
2281
|
-
deps: [PlatformApplication],
|
|
2267
|
+
provide: HttpsServer,
|
|
2268
|
+
deps: [PlatformApplication, Configuration],
|
|
2282
2269
|
scope: ProviderScope.SINGLETON,
|
|
2283
2270
|
global: true,
|
|
2284
2271
|
|
|
2285
|
-
useFactory(platformApplication) {
|
|
2286
|
-
|
|
2272
|
+
useFactory(platformApplication, settings) {
|
|
2273
|
+
const options = settings.httpsOptions;
|
|
2274
|
+
return Https.createServer(options, platformApplication.callback());
|
|
2287
2275
|
}
|
|
2288
2276
|
|
|
2289
2277
|
});
|
|
2290
|
-
async function
|
|
2278
|
+
async function listenHttpsServer(injector) {
|
|
2291
2279
|
const {
|
|
2292
2280
|
settings
|
|
2293
2281
|
} = injector;
|
|
2294
|
-
const server = injector.get(
|
|
2282
|
+
const server = injector.get(HttpsServer);
|
|
2295
2283
|
|
|
2296
|
-
if (settings.
|
|
2284
|
+
if (settings.httpsPort !== false && server) {
|
|
2297
2285
|
const {
|
|
2298
2286
|
address,
|
|
2299
2287
|
port
|
|
2300
|
-
} = settings.
|
|
2301
|
-
injector.logger.debug(`Start server on
|
|
2288
|
+
} = settings.getHttpsPort();
|
|
2289
|
+
injector.logger.debug(`Start server on https://${address}:${port}`);
|
|
2302
2290
|
const options = await listenServer(server, {
|
|
2303
2291
|
address,
|
|
2304
2292
|
port
|
|
2305
2293
|
});
|
|
2306
|
-
settings.
|
|
2307
|
-
injector.logger.info(`Listen server on
|
|
2294
|
+
settings.setHttpsPort(options);
|
|
2295
|
+
injector.logger.info(`Listen server on https://${options.address}:${options.port}`);
|
|
2308
2296
|
}
|
|
2309
2297
|
}
|
|
2310
2298
|
|
|
2311
2299
|
/**
|
|
2312
|
-
* Inject the
|
|
2300
|
+
* Inject the Http.Server instance.
|
|
2313
2301
|
*
|
|
2314
2302
|
* ### Example
|
|
2315
2303
|
*
|
|
2316
2304
|
* ```typescript
|
|
2317
|
-
* import {
|
|
2305
|
+
* import {HttpServer, Service} from "@tsed/common";
|
|
2318
2306
|
*
|
|
2319
2307
|
* @Service()
|
|
2320
2308
|
* export default class OtherService {
|
|
2321
|
-
* constructor(@
|
|
2309
|
+
* constructor(@HttpServer httpServer: HttpServer) {}
|
|
2322
2310
|
* }
|
|
2323
2311
|
* ```
|
|
2324
2312
|
*
|
|
2325
|
-
* > Note: TypeScript transform and store `
|
|
2313
|
+
* > Note: TypeScript transform and store `HttpServer` as `Function` type in the metadata. So to inject a factory, you must use the `@Inject(type)` decorator.
|
|
2326
2314
|
*
|
|
2327
2315
|
* @param {Type<any>} target
|
|
2328
2316
|
* @param {string} targetKey
|
|
@@ -2331,46 +2319,79 @@ async function listenHttpServer(injector) {
|
|
|
2331
2319
|
* @decorator
|
|
2332
2320
|
*/
|
|
2333
2321
|
|
|
2334
|
-
function
|
|
2335
|
-
return Inject(
|
|
2322
|
+
function HttpServer(target, targetKey, descriptor) {
|
|
2323
|
+
return Inject(HttpServer)(target, targetKey, descriptor);
|
|
2336
2324
|
}
|
|
2337
2325
|
|
|
2338
|
-
function
|
|
2339
|
-
injector.
|
|
2326
|
+
function createHttpServer(injector) {
|
|
2327
|
+
injector.invoke(HttpServer);
|
|
2340
2328
|
}
|
|
2341
2329
|
registerProvider({
|
|
2342
|
-
provide:
|
|
2343
|
-
deps: [PlatformApplication
|
|
2330
|
+
provide: HttpServer,
|
|
2331
|
+
deps: [PlatformApplication],
|
|
2344
2332
|
scope: ProviderScope.SINGLETON,
|
|
2345
2333
|
global: true,
|
|
2346
2334
|
|
|
2347
|
-
useFactory(platformApplication
|
|
2348
|
-
|
|
2349
|
-
return Https.createServer(options, platformApplication.callback());
|
|
2335
|
+
useFactory(platformApplication) {
|
|
2336
|
+
return Http.createServer(platformApplication.callback());
|
|
2350
2337
|
}
|
|
2351
2338
|
|
|
2352
2339
|
});
|
|
2353
|
-
async function
|
|
2340
|
+
async function listenHttpServer(injector) {
|
|
2354
2341
|
const {
|
|
2355
2342
|
settings
|
|
2356
2343
|
} = injector;
|
|
2357
|
-
const server = injector.get(
|
|
2344
|
+
const server = injector.get(HttpServer);
|
|
2358
2345
|
|
|
2359
|
-
if (settings.
|
|
2346
|
+
if (settings.httpPort !== false && server) {
|
|
2360
2347
|
const {
|
|
2361
2348
|
address,
|
|
2362
2349
|
port
|
|
2363
|
-
} = settings.
|
|
2364
|
-
injector.logger.debug(`Start server on
|
|
2350
|
+
} = settings.getHttpPort();
|
|
2351
|
+
injector.logger.debug(`Start server on http://${address}:${port}`);
|
|
2365
2352
|
const options = await listenServer(server, {
|
|
2366
2353
|
address,
|
|
2367
2354
|
port
|
|
2368
2355
|
});
|
|
2369
|
-
settings.
|
|
2370
|
-
injector.logger.info(`Listen server on
|
|
2356
|
+
settings.setHttpPort(options);
|
|
2357
|
+
injector.logger.info(`Listen server on http://${options.address}:${options.port}`);
|
|
2371
2358
|
}
|
|
2372
2359
|
}
|
|
2373
2360
|
|
|
2361
|
+
$log.name = "TSED";
|
|
2362
|
+
const DEFAULT_PROVIDERS = [{
|
|
2363
|
+
provide: PlatformHandler
|
|
2364
|
+
}, {
|
|
2365
|
+
provide: PlatformResponse
|
|
2366
|
+
}, {
|
|
2367
|
+
provide: PlatformRequest
|
|
2368
|
+
}, {
|
|
2369
|
+
provide: PlatformRouter
|
|
2370
|
+
}, {
|
|
2371
|
+
provide: PlatformApplication
|
|
2372
|
+
}, {
|
|
2373
|
+
provide: Platform
|
|
2374
|
+
}];
|
|
2375
|
+
function createInjector({
|
|
2376
|
+
providers = [],
|
|
2377
|
+
settings = {}
|
|
2378
|
+
}) {
|
|
2379
|
+
const injector = new InjectorService();
|
|
2380
|
+
injector.addProvider(PlatformConfiguration);
|
|
2381
|
+
injector.settings = injector.invoke(PlatformConfiguration);
|
|
2382
|
+
injector.logger = $log;
|
|
2383
|
+
injector.settings.set(settings);
|
|
2384
|
+
setLoggerLevel(injector);
|
|
2385
|
+
providers = [...DEFAULT_PROVIDERS, ...providers];
|
|
2386
|
+
toMap(providers, "provide").forEach((provider, token) => {
|
|
2387
|
+
injector.addProvider(token, provider);
|
|
2388
|
+
});
|
|
2389
|
+
injector.invoke(PlatformApplication);
|
|
2390
|
+
createHttpsServer(injector);
|
|
2391
|
+
createHttpServer(injector);
|
|
2392
|
+
return injector;
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2374
2395
|
/**
|
|
2375
2396
|
* @ignore
|
|
2376
2397
|
* @deprecated User injector.load(container, module) instead
|
|
@@ -2429,7 +2450,6 @@ function createContext(injector) {
|
|
|
2429
2450
|
|
|
2430
2451
|
const ResponseKlass = (_injector$getProvider = injector.getProvider(PlatformResponse)) == null ? void 0 : _injector$getProvider.useClass;
|
|
2431
2452
|
const RequestKlass = (_injector$getProvider2 = injector.getProvider(PlatformRequest)) == null ? void 0 : _injector$getProvider2.useClass;
|
|
2432
|
-
const platformViews = injector.get(PlatformViews);
|
|
2433
2453
|
|
|
2434
2454
|
const _ref = injector.settings.logger || {},
|
|
2435
2455
|
{
|
|
@@ -2447,7 +2467,6 @@ function createContext(injector) {
|
|
|
2447
2467
|
ResponseKlass,
|
|
2448
2468
|
RequestKlass
|
|
2449
2469
|
}));
|
|
2450
|
-
ctx.response.platformViews = platformViews;
|
|
2451
2470
|
ctx.response.onEnd(async () => {
|
|
2452
2471
|
await ctx.emit("$onResponse", ctx);
|
|
2453
2472
|
await ctx.destroy();
|
|
@@ -2511,19 +2530,6 @@ function getConfiguration(configuration = {}, module = null) {
|
|
|
2511
2530
|
return config;
|
|
2512
2531
|
}
|
|
2513
2532
|
|
|
2514
|
-
const DEFAULT_PROVIDERS = [{
|
|
2515
|
-
provide: PlatformHandler
|
|
2516
|
-
}, {
|
|
2517
|
-
provide: PlatformResponse
|
|
2518
|
-
}, {
|
|
2519
|
-
provide: PlatformRequest
|
|
2520
|
-
}, {
|
|
2521
|
-
provide: PlatformRouter
|
|
2522
|
-
}, {
|
|
2523
|
-
provide: PlatformApplication
|
|
2524
|
-
}, {
|
|
2525
|
-
provide: Platform
|
|
2526
|
-
}];
|
|
2527
2533
|
/**
|
|
2528
2534
|
* @platform
|
|
2529
2535
|
*/
|
|
@@ -2552,7 +2558,13 @@ class PlatformBuilder {
|
|
|
2552
2558
|
this.current = new Date();
|
|
2553
2559
|
this.name = name;
|
|
2554
2560
|
_classPrivateFieldLooseBase(this, _rootModule)[_rootModule] = module;
|
|
2555
|
-
|
|
2561
|
+
const configuration = getConfiguration(settings, module);
|
|
2562
|
+
configuration.PLATFORM_NAME = name;
|
|
2563
|
+
_classPrivateFieldLooseBase(this, _injector)[_injector] = createInjector({
|
|
2564
|
+
settings: configuration,
|
|
2565
|
+
providers
|
|
2566
|
+
});
|
|
2567
|
+
this.log("Injector created...");
|
|
2556
2568
|
}
|
|
2557
2569
|
|
|
2558
2570
|
get injector() {
|
|
@@ -2831,20 +2843,6 @@ class PlatformBuilder {
|
|
|
2831
2843
|
await this.callHook("$afterRoutesInit");
|
|
2832
2844
|
}
|
|
2833
2845
|
|
|
2834
|
-
createInjector(module, providers, settings) {
|
|
2835
|
-
const configuration = getConfiguration(settings, module);
|
|
2836
|
-
configuration.PLATFORM_NAME = this.name;
|
|
2837
|
-
_classPrivateFieldLooseBase(this, _injector)[_injector] = createInjector(configuration);
|
|
2838
|
-
providers = [...DEFAULT_PROVIDERS, ...providers];
|
|
2839
|
-
toMap(providers, "provide").forEach((provider, token) => {
|
|
2840
|
-
this.injector.addProvider(token, provider);
|
|
2841
|
-
});
|
|
2842
|
-
createPlatformApplication(this.injector);
|
|
2843
|
-
createHttpsServer(this.injector);
|
|
2844
|
-
createHttpServer(this.injector);
|
|
2845
|
-
this.log("Injector created...");
|
|
2846
|
-
}
|
|
2847
|
-
|
|
2848
2846
|
}
|
|
2849
2847
|
|
|
2850
2848
|
/**
|
|
@@ -3035,6 +3033,39 @@ function EndpointFn(fn) {
|
|
|
3035
3033
|
return JsonEntityFn(fn);
|
|
3036
3034
|
}
|
|
3037
3035
|
|
|
3036
|
+
/**
|
|
3037
|
+
* Use a view and sends the rendered HTML string to the client. Optional parameter:
|
|
3038
|
+
*
|
|
3039
|
+
* * viewOptions, an object whose properties define local variables for the view.
|
|
3040
|
+
*
|
|
3041
|
+
* The view argument is a string that is the file path of the view file to render.
|
|
3042
|
+
* This can be an absolute path, or a path relative to the views setting.
|
|
3043
|
+
* If the path does not contain a file extension, then the view engine setting determines the file extension.
|
|
3044
|
+
* If the path does contain a file extension, then Express will load the module for the specified template engine (via require())
|
|
3045
|
+
* and render it using the loaded module’s __express function.
|
|
3046
|
+
*
|
|
3047
|
+
* For more information, see [Using template engines with Express](http://expressjs.com/guide/using-template-engines.html).
|
|
3048
|
+
*
|
|
3049
|
+
* > NOTE: The view argument performs file system operations like reading a file from disk and evaluating Node.js modules,
|
|
3050
|
+
* and as so for security reasons should not contain input from the end-user.
|
|
3051
|
+
*
|
|
3052
|
+
* @param path Relative path to the view file.
|
|
3053
|
+
* @param options Additional options
|
|
3054
|
+
* @decorator
|
|
3055
|
+
* @operation
|
|
3056
|
+
* @response
|
|
3057
|
+
* @ignores
|
|
3058
|
+
* @deprecated Use View decorator from @tsed/platform-views instead.
|
|
3059
|
+
*/
|
|
3060
|
+
// istanbul ignore next
|
|
3061
|
+
|
|
3062
|
+
function View(path, options) {
|
|
3063
|
+
return StoreSet("view", {
|
|
3064
|
+
path,
|
|
3065
|
+
options
|
|
3066
|
+
});
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3038
3069
|
/**
|
|
3039
3070
|
* Return the current response data. Prefer the @@Context@@ decorator to get or set data.
|
|
3040
3071
|
*
|
|
@@ -3217,8 +3248,8 @@ function mapReturnedResponse(_ref) {
|
|
|
3217
3248
|
*/
|
|
3218
3249
|
|
|
3219
3250
|
class PlatformTest extends DITest {
|
|
3220
|
-
static async create(
|
|
3221
|
-
DITest.injector = PlatformTest.createInjector(getConfiguration(
|
|
3251
|
+
static async create(settings = {}) {
|
|
3252
|
+
DITest.injector = PlatformTest.createInjector(getConfiguration(settings));
|
|
3222
3253
|
const container = createContainer();
|
|
3223
3254
|
await DITest.injector.load(container);
|
|
3224
3255
|
}
|
|
@@ -3228,7 +3259,10 @@ class PlatformTest extends DITest {
|
|
|
3228
3259
|
|
|
3229
3260
|
|
|
3230
3261
|
static createInjector(settings = {}) {
|
|
3231
|
-
return createInjector(
|
|
3262
|
+
return createInjector({
|
|
3263
|
+
providers: [],
|
|
3264
|
+
settings: DITest.configure(settings)
|
|
3265
|
+
});
|
|
3232
3266
|
}
|
|
3233
3267
|
/**
|
|
3234
3268
|
* Load the server silently without listening port and configure it on test profile.
|
|
@@ -3392,7 +3426,7 @@ class PlatformTest extends DITest {
|
|
|
3392
3426
|
request: (options == null ? void 0 : (_options$request = options.request) == null ? void 0 : _options$request.request) || (options == null ? void 0 : (_options$event = options.event) == null ? void 0 : _options$event.request) || PlatformTest.createRequest(),
|
|
3393
3427
|
response: (options == null ? void 0 : (_options$response = options.response) == null ? void 0 : _options$response.response) || (options == null ? void 0 : (_options$event2 = options.event) == null ? void 0 : _options$event2.response) || PlatformTest.createResponse()
|
|
3394
3428
|
};
|
|
3395
|
-
|
|
3429
|
+
return new PlatformContext(_extends({
|
|
3396
3430
|
id: "id",
|
|
3397
3431
|
injector: DITest.injector,
|
|
3398
3432
|
logger: DITest.injector.logger,
|
|
@@ -3400,8 +3434,6 @@ class PlatformTest extends DITest {
|
|
|
3400
3434
|
}, options, {
|
|
3401
3435
|
event
|
|
3402
3436
|
}));
|
|
3403
|
-
ctx.response.platformViews = PlatformTest.get(PlatformViews);
|
|
3404
|
-
return ctx;
|
|
3405
3437
|
}
|
|
3406
3438
|
|
|
3407
3439
|
}
|
|
@@ -3412,5 +3444,5 @@ class PlatformTest extends DITest {
|
|
|
3412
3444
|
*/
|
|
3413
3445
|
class PlatformModule {}
|
|
3414
3446
|
|
|
3415
|
-
export { AcceptMime, AcceptMimesMiddleware, AnyToPromiseWithCtx, ControllerProvider, EndpointFn, EndpointInfo, EndpointMetadata, Err, GlobalAcceptMimesMiddleware, HandlerMetadata, HandlerType, HttpServer, HttpsServer, MulterFileSize, MulterOptions, MultipartFile, Next, PLATFORM_ROUTER_OPTIONS, Platform, PlatformAcceptMimesMiddleware, PlatformApplication, PlatformBuilder, PlatformConfiguration, PlatformContext, PlatformHandler, PlatformMiddlewaresChain, PlatformModule, PlatformMulterMiddleware, PlatformRequest, PlatformResponse, PlatformRouteDetails, PlatformRouter, PlatformTest, PropertyMetadata, ROUTER_OPTIONS, Req, Request, Res, Response, ResponseData, bindEndpointMiddleware, buildRouter, createContext, createHttpServer, createHttpsServer, createInjector,
|
|
3447
|
+
export { AcceptMime, AcceptMimesMiddleware, AnyToPromiseWithCtx, ControllerProvider, EndpointFn, EndpointInfo, EndpointMetadata, Err, GlobalAcceptMimesMiddleware, HandlerMetadata, HandlerType, HttpServer, HttpsServer, MulterFileSize, MulterOptions, MultipartFile, Next, PLATFORM_ROUTER_OPTIONS, Platform, PlatformAcceptMimesMiddleware, PlatformApplication, PlatformBuilder, PlatformConfiguration, PlatformContext, PlatformHandler, PlatformMiddlewaresChain, PlatformModule, PlatformMulterMiddleware, PlatformRequest, PlatformResponse, PlatformRouteDetails, PlatformRouter, PlatformTest, PropertyMetadata, ROUTER_OPTIONS, Req, Request, Res, Response, ResponseData, View, bindEndpointMiddleware, buildRouter, createContext, createHttpServer, createHttpsServer, createInjector, createRouter, getRouter, listenHttpServer, listenHttpsServer, listenServer, loadInjector, mapReturnedResponse, printRoutes, useCtxHandler };
|
|
3416
3448
|
//# sourceMappingURL=index.modern.js.map
|