<commit_before>/**
 * Gorgon the scripting capable network server for Node JS
 *
 * @package Gorgon
 * @author <NAME>
 * @license MIT
 * @url https://github.com/manufacturing-industry
 */

import _ from 'lodash';

export class Routes {
    construct(serviceName) {
        this.service = serviceName;
        this.inboundTypes = ['rest', 'socket', 'http', 'https', 'webSocket', 'api'];
        this.routes = [];
        this.routeCallbacks = [];
        this.permissionMap = [];
    }

    add(inboundTypes, method, callback)
    {
        this.routes.push(method);
        this.routeCallbacks(callback);
        var pos = this.routeCallbacks.length - 1;

        inboundTypes.forEach(function(value){
            if (this.inboundTypes.indexOf(value) > -1) this.permissionMap[value].push(pos);
            else console.log('ERROR - Invalid Permission Encountered in Service: [' + this.service + '] Method: [' + method + ']');
        });
    }

    remove(method)
    {
        let pos = this.routes.indexOf(method);
        if (pos > -1)
        {
            this.routeCallbacks[pos] = null;
            this.routes[pos] = null;

            this.inboundTypes.forEach(function(value)
            {
                if (this.permissionMap[value] != undefined && this.permissionMap[value] instanceof Array)
                {
                    let keyPos = this.permissionMap[value].indexOf(pos);
                    if (keyPos > -1) this.permissionMap[value].splice(keyPos, 1);
                }
            });
            return true;
        }
        return false;
    }

    route(inboundType, method, payload)
    {
        let pos = this.routes.indexOf(method);
        if (pos > -1)
        {
            if (this.permissionMap[inboundType] != undefined && this.permissionMap[inboundType].length > 0 && this.permissionMap[inboundType].indexOf(pos) > -1)
            {
                //callback exists for method
                return this.routeCallbacks[pos](method, inboundType, ...payload);
            }
        }
        return false;
    }
}

export class RouteItem
{
    construct(service, method, commandCallback)
    {
        this.service = service;
        this.method = method;
        this.command = commandCallback;
    }

    call(payload)
    {
        return this.command(...payload);
    }
}<commit_msg>Updates router class removing RouteItem class<commit_after>/**
 * Gorgon the scripting capable network server for Node JS
 *
 * @package Gorgon
 * @author <NAME>
 * @license MIT
 * @url https://github.com/manufacturing-industry
 */

import _ from 'lodash';

export class Routes {
    construct(serviceName) {
        this.service = serviceName;
        this.inboundTypes = ['rest', 'socket', 'http', 'https', 'webSocket', 'api'];
        this.routes = [];
        this.routeCallbacks = [];
        this.permissionMap = [];
    }

    add(inboundTypes, method, callback)
    {
        this.routes.push(method);
        this.routeCallbacks(callback);
        var pos = this.routeCallbacks.length - 1;

        inboundTypes.forEach(function(value){
            if (this.inboundTypes.indexOf(value) > -1) this.permissionMap[value].push(pos);
            else console.log('ERROR - Invalid Permission Encountered in Service: [' + this.service + '] Method: [' + method + ']');
        });
    }

    remove(method)
    {
        let pos = this.routes.indexOf(method);
        if (pos > -1)
        {
            this.routeCallbacks[pos] = null;
            this.routes[pos] = null;

            this.inboundTypes.forEach(function(value)
            {
                if (this.permissionMap[value] != undefined && this.permissionMap[value] instanceof Array)
                {
                    let keyPos = this.permissionMap[value].indexOf(pos);
                    if (keyPos > -1) this.permissionMap[value].splice(keyPos, 1);
                }
            });
            return true;
        }
        return false;
    }

    route(inboundType, method, payload)
    {
        let pos = this.routes.indexOf(method);
        if (pos > -1)
        {
            if (this.permissionMap[inboundType] != undefined && this.permissionMap[inboundType].length > 0 && this.permissionMap[inboundType].indexOf(pos) > -1)
            {
                //callback exists for method
                return this.routeCallbacks[pos](method, inboundType, ...payload);
            }
        }
        return false;
    }
}
{'fraction_non_alphanumeric': 0.12770758122743683, 'fraction_numerical': 0.0036101083032490976, 'mean_word_length': 1.9416058394160585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5360521', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1244, 'n_words': 254}