Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const morgan = require('morgan')
const logger = require('../utils/logger')(__filename)
const { CORRELATION_HEADER } = require('../../config/correlation_header')
const { format } = require('@govuk-pay/pay-js-commons').logging.requestLogFormat(CORRELATION_HEADER)
module.exports = function () {
return morgan(format, {
stream: {
write: message => {
logger.info('Request received', JSON.parse(message))
}
}
})
}
const _ = require('lodash')
const logger = require('./logger')(__filename)
const displayConverter = require('./display_converter')
const { CORRELATION_ID } = require('@govuk-pay/pay-js-commons').logging.keys
const ERROR_MESSAGE = 'There is a problem with the payments platform'
const ERROR_VIEW = 'error'
function response (req, res, template, data = {}) {
let convertedData = displayConverter(req, data, template)
render(req, res, template, convertedData)
}
function errorResponse (req, res, msg, status = 500) {
if (!msg) msg = ERROR_MESSAGE
let correlationId = req.correlationId
if (typeof msg !== 'string') {
msg = 'Please try again or contact support team.'
}
let data = { 'message': msg }
const { createLogger, format, transports } = require('winston')
const { json, splat, prettyPrint } = format
const { govUkPayLoggingFormat } = require('@govuk-pay/pay-js-commons').logging
const { addSentryToErrorLevel } = require('./sentry.js')
const logger = createLogger({
format: format.combine(
splat(),
prettyPrint(),
govUkPayLoggingFormat({ container: 'selfservice', environment: process.env.ENVIRONMENT }),
json()
),
transports: [
new transports.Console()
]
})
module.exports = (loggerName) => {
const childLogger = logger.child({ logger_name: loggerName })
const { createLogger, format, transports } = require('winston')
const { json, splat, prettyPrint } = format
const { govUkPayLoggingFormat } = require('@govuk-pay/pay-js-commons').logging
const { addSentryToErrorLevel } = require('./sentry.js')
const logger = createLogger({
format: format.combine(
splat(),
prettyPrint(),
govUkPayLoggingFormat({ container: 'frontend', environment: process.env.ENVIRONMENT }),
json()
),
transports: [
new transports.Console()
]
})
module.exports = (loggerName) => {
const childLogger = logger.child({ logger_name: loggerName })
'use strict'
const { PAYMENT_EXTERNAL_ID } = require('@govuk-pay/pay-js-commons').logging.keys
const logger = require('../utils/logger')(__filename)
const { setLoggingField, getLoggingFields } = require('../utils/logging_fields_helper')
const cookie = require('../utils/cookies')
exports.retrieve = req => {
const chargeId = req.params.chargeId ? req.params.chargeId : req.body.chargeId
setLoggingField(req, PAYMENT_EXTERNAL_ID, chargeId)
if (!chargeId) {
logger.error('ChargeId was not found in request', getLoggingFields(req))
return false
} else if (!cookie.getSessionCookieName() || !cookie.isSessionPresent(req)) {
logger.info('Session cookie is not present', {
...getLoggingFields(req),
referrer: req.get('Referrer'),
url: req.originalUrl,
const morgan = require('morgan')
const logger = require('../utils/logger')(__filename)
const { CORRELATION_HEADER } = require('../utils/correlation_header')
const { format } = require('@govuk-pay/pay-js-commons').logging.requestLogFormat(CORRELATION_HEADER)
module.exports = function () {
return morgan(format, {
stream: {
write: message => {
logger.info('Request received', JSON.parse(message))
}
}
})
}