Source: models/tcp/tcpRequest.js

'use strict';

/**
 * Transforms a raw tcp request into the API-friendly representation of one
 * @module
 */

/**
 * Creates the request used during dry run validation
 * @returns {Object}
 */
const createTestRequest = () => ({
    requestFrom: '',
    data: 'test'
});

/**
 * Transforms the raw tcp request into a mountebank tcp request
 * @param {Object} request - The raw tcp request
 * @returns {Object} - A promise resolving to the mountebank tcp request
 */
const createFrom = request => {
    const Q = require('q'),
        helpers = require('../../util/helpers');

    return Q({
        requestFrom: helpers.socketName(request.socket),
        data: request.data
    });
};

module.exports = { createTestRequest, createFrom };