All files helpers.js

25% Statements 2/8
0% Branches 0/6
0% Functions 0/2
25% Lines 2/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 381x                                                                 1x        
const { v4: uuidv4 } = require('uuid');
 
function getDefaults() {
    return {
        raw: {
            json: true
        },
        method: 'POST',
        headers: {
            sourceSystem: 'DigitalWallet',
            targetSystem: 'ESB',
            priority: 0,
            userLanguage: 'BG'
        }
    };
}
 
function getDynamicHeaders($meta = {}) {
    const now = new Date();
    const transactionTimeStamp = now.toISOString();
    const transactionDateStamp = new Date(now.getTime() + (now.getTimezoneOffset() * 60 * 1000)).toISOString().split('T')[0];
 
    const headers = {
        transactionId: uuidv4(),
        transactionUser: $meta?.auth?.actorId || 'Wallet',
        transactionDateStamp,
        transactionTimeStamp,
        CustomerIDResourceOwner: $meta.CustomerIDResourceOwner || $meta?.auth?.handle || 'Unauthenticated'
    };
 
    return headers;
}
 
module.exports = {
    getDefaults,
    getDynamicHeaders
};