@podium/context
Advanced tools
Comparing version 3.0.0-beta.3 to 3.0.0-beta.4
@@ -8,3 +8,2 @@ 'use strict'; | ||
const utils = require('@podium/utils'); | ||
const boom = require('boom'); | ||
const joi = require('joi'); | ||
@@ -18,3 +17,2 @@ const PublicPathname = require('./get-public-pathname'); | ||
const Debug = require('./get-debug'); | ||
const State = require('./state'); | ||
@@ -85,2 +83,8 @@ const PREFIX = 'podium'; | ||
const timer = this.metrics.timer({ | ||
name: 'context_run_parsers', | ||
description: | ||
'Time taken to run all context parsers', | ||
}); | ||
const parsers = Array.from(this.parsers); | ||
@@ -96,2 +100,5 @@ return Promise.all( | ||
}); | ||
timer(); | ||
return state; | ||
@@ -101,39 +108,2 @@ }); | ||
middleware() { | ||
return async (req, res, next) => { | ||
const successTimer = this.metrics.timer({ | ||
name: 'context_run_parsers_success', | ||
description: | ||
'Time taken to successfully run all context parsers', | ||
}); | ||
const failureTimer = this.metrics.timer({ | ||
name: 'context_run_parsers_failure', | ||
description: | ||
'Time taken for failure to occur when running all context parsers', | ||
}); | ||
let state = new State(req, res, res.locals); | ||
try { | ||
state = await this.process(state); | ||
successTimer(); | ||
if (state) { | ||
utils.setAtLocalsPodium(res, 'context', state.context); | ||
next(); | ||
} | ||
} catch (error) { | ||
const message = `Error during context parsing or serializing`; | ||
failureTimer({ | ||
meta: { | ||
message, | ||
error: error.message, | ||
stack: error.stack, | ||
}, | ||
}); | ||
next(boom.badGateway(message, error)); | ||
} | ||
}; | ||
} | ||
static serialize(headers, context, name) { | ||
@@ -140,0 +110,0 @@ return utils.serializeContext(headers, context, name); |
@@ -41,3 +41,2 @@ 'use strict'; | ||
enumerable: true, | ||
writable: true, | ||
value: {}, | ||
@@ -44,0 +43,0 @@ }); |
{ | ||
"name": "@podium/context", | ||
"version": "3.0.0-beta.3", | ||
"version": "3.0.0-beta.4", | ||
"description": "Module to generate the context which is passed on requests from a Layout server to a Podlet server", | ||
@@ -37,3 +37,2 @@ "license": "MIT", | ||
"bcp47-validate": "^1.0.0", | ||
"boom": "^7.2.0", | ||
"bowser": "^2.1.0", | ||
@@ -40,0 +39,0 @@ "decamelize": "^2.0.0", |
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
9
33843
377
- Removedboom@^7.2.0
- Removedboom@7.3.0(transitive)