@scvo/router
Advanced tools
Comparing version
@@ -38,2 +38,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var util = require("util"); | ||
var RouteMatch = /** @class */ (function () { | ||
@@ -47,7 +48,10 @@ function RouteMatch(route, request, context) { | ||
contentType: 'application/json', | ||
contentBody: '{}', | ||
statusCode: 200 | ||
body: '{}', | ||
statusCode: 200, | ||
headers: {}, | ||
cookies: {}, | ||
}; | ||
this.layoutName = 'default'; | ||
this.route.tasks = this.route.tasks || []; | ||
this.response.cookies = request.cookies; | ||
} | ||
@@ -72,3 +76,3 @@ RouteMatch.prototype.execute = function () { | ||
this.response.contentType = 'application/json'; | ||
this.response.contentBody = JSON.stringify(err_1, null, 4); | ||
this.response.body = JSON.stringify(err_1, null, 4); | ||
return [3 /*break*/, 4]; | ||
@@ -116,16 +120,17 @@ case 4: return [2 /*return*/]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var routerDestination, _a, err_3; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var routerDestination, response, err_3; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
console.log('#### RouteMatch -> Route:', this.route); | ||
_a.trys.push([0, 2, , 3]); | ||
console.log('#### RouteMatch.runDestination ->', util.inspect(this, false, null, true)); | ||
routerDestination = this.context.routerDestinations[this.route.destination.destinationType]; | ||
_a = this; | ||
return [4 /*yield*/, routerDestination.execute(this)]; | ||
case 1: | ||
_a.response = _b.sent(); | ||
response = _a.sent(); | ||
Object.assign(this.response, response); | ||
this.response.cookies = response.cookies; // Overwriting these in case cookies are cleared in the response | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
err_3 = _b.sent(); | ||
err_3 = _a.sent(); | ||
console.error('#### RouteMatch -> Failed to run destination:', err_3); | ||
@@ -132,0 +137,0 @@ throw err_3; |
{ | ||
"name": "@scvo/router", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A moderately oppinionated web application framework based around mapping routes to tasks and then rendering with handlebars", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -57,3 +57,2 @@ import * as util from 'util'; | ||
try { | ||
console.log('#### RouteMatch -> Route:', this.route); | ||
var routerDestination = this.context.routerDestinations[this.route.destination.destinationType]; | ||
@@ -60,0 +59,0 @@ var response = await routerDestination.execute(this); |
Sorry, the diff of this file is not supported yet
261656
0.19%2600
0.15%