@tsed/platform-views
Advanced tools
Comparing version 6.87.2 to 6.88.0
@@ -57,2 +57,3 @@ import { BaseContext } from "@tsed/di"; | ||
export interface PlatformViewsSettings { | ||
disabled?: boolean; | ||
/** | ||
@@ -59,0 +60,0 @@ * Views directory. |
export * from "./decorators/view"; | ||
export * from "./domain/PlatformViewsSettings"; | ||
export * from "./services/PlatformViews"; | ||
export * from "./errors/TemplateRenderError"; | ||
export * from "./utils/renderView"; |
@@ -6,3 +6,2 @@ var core = require('@tsed/core'); | ||
var path = require('path'); | ||
var exceptions = require('@tsed/exceptions'); | ||
@@ -199,5 +198,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
async $onInit() { | ||
_classPrivateFieldLooseBase(this, _extensions)[_extensions] = new Map(Object.entries(_extends({}, PLATFORM_VIEWS_EXTENSIONS, this.extensionsOptions))); | ||
await this.loadFromConsolidate(); | ||
await this.loadFromTsedEngines(); | ||
if (!this.disabled) { | ||
_classPrivateFieldLooseBase(this, _extensions)[_extensions] = new Map(Object.entries(_extends({}, PLATFORM_VIEWS_EXTENSIONS, this.extensionsOptions))); | ||
await this.loadFromConsolidate(); | ||
await this.loadFromTsedEngines(); | ||
} | ||
} | ||
@@ -318,2 +319,4 @@ /** | ||
tslib.__decorate([di.Constant("views.disabled", false), tslib.__metadata("design:type", String)], exports.PlatformViews.prototype, "disabled", void 0); | ||
tslib.__decorate([di.Constant("views.viewEngine", "ejs"), tslib.__metadata("design:type", String)], exports.PlatformViews.prototype, "viewEngine", void 0); | ||
@@ -325,55 +328,10 @@ | ||
exports.PlatformViews = tslib.__decorate([di.Injectable()], exports.PlatformViews); | ||
/** | ||
* @private | ||
*/ | ||
class TemplateRenderError extends exceptions.InternalServerError { | ||
constructor(target, method, err) { | ||
super(TemplateRenderError.buildMessage(target, method, err)); | ||
this.name = "TEMPLATE_RENDER_ERROR"; | ||
exports.PlatformViews = tslib.__decorate([di.Module({ | ||
views: { | ||
exists: true | ||
} | ||
/** | ||
* | ||
* @returns {string} | ||
*/ | ||
})], exports.PlatformViews); | ||
static buildMessage(target, method, err) { | ||
return `Template rendering error: ${core.nameOf(target)}.${String(method)}()\n` + err; | ||
} | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
async function renderView(data, $ctx) { | ||
const { | ||
response, | ||
endpoint | ||
} = $ctx; | ||
try { | ||
const { | ||
data | ||
} = $ctx; | ||
const { | ||
path, | ||
options | ||
} = endpoint.view; | ||
return await response.render(path, _extends({}, options, data, { | ||
$ctx | ||
})); | ||
} catch (err) { | ||
throw new TemplateRenderError(endpoint.targetName, endpoint.propertyKey, err); | ||
} | ||
} | ||
exports.PLATFORM_VIEWS_EXTENSIONS = PLATFORM_VIEWS_EXTENSIONS; | ||
exports.TemplateRenderError = TemplateRenderError; | ||
exports.View = View; | ||
exports.renderView = renderView; | ||
//# sourceMappingURL=index.js.map |
@@ -1,7 +0,6 @@ | ||
import { StoreSet, getValue, Env, nameOf } from '@tsed/core'; | ||
import { StoreSet, getValue, Env } from '@tsed/core'; | ||
import { __decorate, __metadata } from 'tslib'; | ||
import { Constant, Injectable } from '@tsed/di'; | ||
import { Constant, Module } from '@tsed/di'; | ||
import Fs from 'fs'; | ||
import { extname, resolve, join } from 'path'; | ||
import { InternalServerError } from '@tsed/exceptions'; | ||
@@ -174,5 +173,7 @@ /** | ||
async $onInit() { | ||
_classPrivateFieldLooseBase(this, _extensions)[_extensions] = new Map(Object.entries(_extends({}, PLATFORM_VIEWS_EXTENSIONS, this.extensionsOptions))); | ||
await this.loadFromConsolidate(); | ||
await this.loadFromTsedEngines(); | ||
if (!this.disabled) { | ||
_classPrivateFieldLooseBase(this, _extensions)[_extensions] = new Map(Object.entries(_extends({}, PLATFORM_VIEWS_EXTENSIONS, this.extensionsOptions))); | ||
await this.loadFromConsolidate(); | ||
await this.loadFromTsedEngines(); | ||
} | ||
} | ||
@@ -293,2 +294,4 @@ /** | ||
__decorate([Constant("views.disabled", false), __metadata("design:type", String)], PlatformViews.prototype, "disabled", void 0); | ||
__decorate([Constant("views.viewEngine", "ejs"), __metadata("design:type", String)], PlatformViews.prototype, "viewEngine", void 0); | ||
@@ -300,52 +303,9 @@ | ||
PlatformViews = __decorate([Injectable()], PlatformViews); | ||
/** | ||
* @private | ||
*/ | ||
class TemplateRenderError extends InternalServerError { | ||
constructor(target, method, err) { | ||
super(TemplateRenderError.buildMessage(target, method, err)); | ||
this.name = "TEMPLATE_RENDER_ERROR"; | ||
PlatformViews = __decorate([Module({ | ||
views: { | ||
exists: true | ||
} | ||
/** | ||
* | ||
* @returns {string} | ||
*/ | ||
})], PlatformViews); | ||
static buildMessage(target, method, err) { | ||
return `Template rendering error: ${nameOf(target)}.${String(method)}()\n` + err; | ||
} | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
async function renderView(data, $ctx) { | ||
const { | ||
response, | ||
endpoint | ||
} = $ctx; | ||
try { | ||
const { | ||
data: _data | ||
} = $ctx; | ||
const { | ||
path, | ||
options | ||
} = endpoint.view; | ||
return await response.render(path, _extends({}, options, _data, { | ||
$ctx | ||
})); | ||
} catch (err) { | ||
throw new TemplateRenderError(endpoint.targetName, endpoint.propertyKey, err); | ||
} | ||
} | ||
export { PLATFORM_VIEWS_EXTENSIONS, PlatformViews, TemplateRenderError, View, renderView }; | ||
export { PLATFORM_VIEWS_EXTENSIONS, PlatformViews, View }; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -11,2 +11,3 @@ import { Env } from "@tsed/core"; | ||
readonly cache: boolean; | ||
readonly disabled: string; | ||
readonly viewEngine: string; | ||
@@ -13,0 +14,0 @@ protected extensionsOptions: PlatformViewsExtensionsTypes; |
{ | ||
"name": "@tsed/platform-views", | ||
"version": "6.87.2", | ||
"version": "6.88.0", | ||
"description": "Views module for Ts.ED Framework", | ||
@@ -22,15 +22,15 @@ "private": false, | ||
"devDependencies": { | ||
"@tsed/core": "6.87.2", | ||
"@tsed/di": "6.87.2", | ||
"@tsed/core": "6.88.0", | ||
"@tsed/di": "6.88.0", | ||
"@tsed/engines": "^1.1.5", | ||
"@tsed/exceptions": "6.87.2", | ||
"@tsed/schema": "6.87.2", | ||
"@tsed/exceptions": "6.88.0", | ||
"@tsed/schema": "6.88.0", | ||
"@types/consolidate": "0.14.0" | ||
}, | ||
"peerDependencies": { | ||
"@tsed/core": "^6.87.2", | ||
"@tsed/di": "^6.87.2", | ||
"@tsed/core": "^6.88.0", | ||
"@tsed/di": "^6.88.0", | ||
"@tsed/engines": "^1.1.5", | ||
"@tsed/exceptions": "^6.87.2", | ||
"@tsed/schema": "^6.87.2" | ||
"@tsed/exceptions": "^6.88.0", | ||
"@tsed/schema": "^6.88.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "repository": "https://github.com/tsedio/tsed", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58421
10
677