@tsed/common 6.87.2 → 6.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +54 -23
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +54 -17
- 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/package.json +15 -15
package/lib/index.modern.js
CHANGED
|
@@ -11,8 +11,6 @@ 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';
|
|
@@ -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;
|
|
@@ -2442,7 +2450,6 @@ function createContext(injector) {
|
|
|
2442
2450
|
|
|
2443
2451
|
const ResponseKlass = (_injector$getProvider = injector.getProvider(PlatformResponse)) == null ? void 0 : _injector$getProvider.useClass;
|
|
2444
2452
|
const RequestKlass = (_injector$getProvider2 = injector.getProvider(PlatformRequest)) == null ? void 0 : _injector$getProvider2.useClass;
|
|
2445
|
-
const platformViews = injector.get(PlatformViews);
|
|
2446
2453
|
|
|
2447
2454
|
const _ref = injector.settings.logger || {},
|
|
2448
2455
|
{
|
|
@@ -2460,7 +2467,6 @@ function createContext(injector) {
|
|
|
2460
2467
|
ResponseKlass,
|
|
2461
2468
|
RequestKlass
|
|
2462
2469
|
}));
|
|
2463
|
-
ctx.response.platformViews = platformViews;
|
|
2464
2470
|
ctx.response.onEnd(async () => {
|
|
2465
2471
|
await ctx.emit("$onResponse", ctx);
|
|
2466
2472
|
await ctx.destroy();
|
|
@@ -3027,6 +3033,39 @@ function EndpointFn(fn) {
|
|
|
3027
3033
|
return JsonEntityFn(fn);
|
|
3028
3034
|
}
|
|
3029
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
|
+
|
|
3030
3069
|
/**
|
|
3031
3070
|
* Return the current response data. Prefer the @@Context@@ decorator to get or set data.
|
|
3032
3071
|
*
|
|
@@ -3387,7 +3426,7 @@ class PlatformTest extends DITest {
|
|
|
3387
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(),
|
|
3388
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()
|
|
3389
3428
|
};
|
|
3390
|
-
|
|
3429
|
+
return new PlatformContext(_extends({
|
|
3391
3430
|
id: "id",
|
|
3392
3431
|
injector: DITest.injector,
|
|
3393
3432
|
logger: DITest.injector.logger,
|
|
@@ -3395,8 +3434,6 @@ class PlatformTest extends DITest {
|
|
|
3395
3434
|
}, options, {
|
|
3396
3435
|
event
|
|
3397
3436
|
}));
|
|
3398
|
-
ctx.response.platformViews = PlatformTest.get(PlatformViews);
|
|
3399
|
-
return ctx;
|
|
3400
3437
|
}
|
|
3401
3438
|
|
|
3402
3439
|
}
|
|
@@ -3407,5 +3444,5 @@ class PlatformTest extends DITest {
|
|
|
3407
3444
|
*/
|
|
3408
3445
|
class PlatformModule {}
|
|
3409
3446
|
|
|
3410
|
-
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, createRouter, getRouter, listenHttpServer, listenHttpsServer, listenServer, loadInjector, mapReturnedResponse, printRoutes, useCtxHandler };
|
|
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 };
|
|
3411
3448
|
//# sourceMappingURL=index.modern.js.map
|