Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
const { fromDateTime, toDateTime } = getTransactionDateRange(period)
const transactionsPeriodString = `fromDate=${encodeURIComponent(datetime(fromDateTime, 'date'))}&fromTime=${encodeURIComponent(datetime(fromDateTime, 'time'))}&toDate=${encodeURIComponent(datetime(toDateTime, 'date'))}&toTime=${encodeURIComponent(datetime(toDateTime, 'time'))}`
logger.info(`[${correlationId}] successfully logged in`)
if (isADirectDebitAccount(gatewayAccountId)) {
// todo implement transaction list for direct debit
return response(req, res, 'dashboard/index', Object.assign(model, {
activityError: true
}))
}
const namespace = getNamespace(clsXrayConfig.nameSpaceName)
const clsSegment = namespace.get(clsXrayConfig.segmentKeyName)
AWSXRay.captureAsyncFunc('ledgerClient_getTransactionSummary', function (subsegment) {
LedgerClient.transactionSummary(gatewayAccountId, fromDateTime, toDateTime, { correlationId: correlationId })
.then(result => {
subsegment.close()
response(req, res, 'dashboard/index', Object.assign(model, {
activity: result,
successfulTransactionsState: 'payment-success',
fromDateTime,
toDateTime,
transactionsPeriodString
}))
})
.catch((error, ledgerResponse) => {
subsegment.close(error)
this.rewriters.push((level, msg, meta) => {
const namespace = cls.getNamespace(config.get('turing:logging:namespace'));
const request = namespace.get('request');
const uuid = namespace.get('uuid');
const metaFromConf = config.get('turing:logging:meta');
if (uuid) {
meta.uuid = uuid;
}
meta.caller = findCaller();
if (request) {
const headers = config.get('turing:logging:headers');
headers.forEach((header) => {
const value = request.headers[header];
if (value) {
meta[header] = value;
function deserializeUser (req, externalId, done) {
const segment = new AWSXRay.Segment('deserialize')
const namespace = getNamespace(clsXrayConfig.nameSpaceName)
namespace.run(() => {
namespace.set(clsXrayConfig.segmentKeyName, segment)
AWSXRay.captureAsyncFunc('auth_service_deserializeUser', function (subSegment) {
return userService.findByExternalId(externalId, req.headers[CORRELATION_HEADER] || '', subSegment)
.then((user) => {
segment.close()
done(null, user)
})
.catch(err => {
segment.close(err)
logger.info(`[${req.correlationId}]: Failed to retrieve user, '${externalId}', from adminusers with statuscode: ${err.errorCode}`)
done(err)
})
}, segment)
})
}
constructor(namespace = 'zipkin') {
this._session = getNamespace(namespace) || createNamespace(namespace);
const defaultContext = this._session.createContext();
this._session.enter(defaultContext);
}
bind(...args) {
return getNamespace(this.name).bind(...args);
}
const {createNamespace, getNamespace} = require('continuation-local-storage');
const randomTraceId = require('./randomTraceId');
const Annotation = require('./annotation');
const TraceId = require('./TraceId');
const {now} = require('./time');
const {Some, None, fromNullable} = require('./option');
const trace = {};
const session = getNamespace('zipkin') || createNamespace('zipkin');
const defaultContext = session.createContext();
session.enter(defaultContext);
function State({id, terminal, tracers}) {
this.id = id;
this.terminal = terminal;
this.tracers = tracers;
}
State.prototype.toString = function() {
return `State(id=${this.id.toString()}, terminal=${this.terminal}, tracers=[${
this.tracers.map(t => t.toString()).join(', ')
}])`;
};
const defaultId = new TraceId({
traceId: None,
get(key) {
return getNamespace(this.name).get(key);
}
module.exports = (req, res, next) => {
const namespace = getNamespace(clsXrayConfig.nameSpaceName)
namespace.set(clsXrayConfig.segmentKeyName, req.segment)
next()
}
set(key, value) {
getNamespace(this.name).set(key, value);
return this;
}