<commit_before>/* jslint node: true, esnext: true */

"use strict";

const parentStep = require('kronos-adapter-inbound-http').AdapterInboundHttp,
	route = require('koa-route'),
	Step = require('kronos-step');

const httpRoutingStep = Object.assign({}, parentStep, {
	"name": "kronos-http-routing",
	"description": "routes http requests to endpoints",
	initialize(manager, scopeReporter, name, stepConfiguration, endpoints, props) {
		parentStep.initialize(manager, scopeReporter, name, stepConfiguration, endpoints, props);

		for (let path in stepConfiguration.routes) {
			const r = stepConfiguration.routes[path];

			const name = r.name || path;
			const endpointOptions = {
				out: true,
				active: true,
				target: r.target
			};
			r.endpoint = endpoints[name] = Step.createEndpoint(name, endpointOptions);
			//console.log(`endpoint: ${r.endpoint}`);
		}

		props.routes = {
			value: stepConfiguration.routes
		};
	},

	_doRegisterUrls() {
		const self = this;
		for (let path in this.routes) {
			const r = this.routes[path];
			let method, methodName;

			if (r.method) {
				methodName = r.method.toLowerCase();
				method = route[methodName];
			} else {
				methodName = 'get';
				method = route.get;
			}

			this.registerRoute(method(path, (ctx) => {
				const request = ctx.request;
				const info = {
					request: request
				};

				this.info(`${methodName} ${path}`);

				if (r.content) {
					r.endpoint.send({
						info: info,
						content: r.content
					});
				} else {
					r.endpoint.send({
						info: info,
						stream: ctx.req
					});
				}
				ctx.body = "OK";
			}));
		}
	}

});

exports.registerWithManager = function (manager) {
	manager.registerStep(httpRoutingStep);
};<commit_msg>refactor: removed some unused variables<commit_after>/* jslint node: true, esnext: true */

"use strict";

const parentStep = require('kronos-adapter-inbound-http').AdapterInboundHttp,
	route = require('koa-route'),
	Step = require('kronos-step');

const httpRoutingStep = Object.assign({}, parentStep, {
	"name": "kronos-http-routing",
	"description": "routes http requests to endpoints",
	initialize(manager, scopeReporter, name, stepConfiguration, endpoints, props) {
		parentStep.initialize(manager, scopeReporter, name, stepConfiguration, endpoints, props);

		for (let path in stepConfiguration.routes) {
			const r = stepConfiguration.routes[path];

			const name = r.name || path;
			const endpointOptions = {
				out: true,
				active: true,
				target: r.target
			};
			r.endpoint = endpoints[name] = Step.createEndpoint(name, endpointOptions);
			//console.log(`endpoint: ${r.endpoint}`);
		}

		props.routes = {
			value: stepConfiguration.routes
		};
	},

	_doRegisterUrls() {
		for (let path in this.routes) {
			const r = this.routes[path];
			let method, methodName;

			if (r.method) {
				methodName = r.method.toLowerCase();
				method = route[methodName];
			} else {
				methodName = 'get';
				method = route.get;
			}

			this.info(`add route: ${methodName} ${path}`);

			this.registerRoute(method(path, ctx => {
				this.info(`${methodName} ${path}`);

				const request = ctx.request;
				const info = {
					request: request
				};

				if (r.content) {
					r.endpoint.send({
						info: info,
						content: r.content
					});
				} else {
					r.endpoint.send({
						info: info,
						stream: ctx.req
					});
				}
				ctx.body = "OK";
			}));
		}
	}
});

exports.registerWithManager = function (manager) {
	manager.registerStep(httpRoutingStep);
};
{'fraction_non_alphanumeric': 0.14867559099971517, 'fraction_numerical': 0.0, 'mean_word_length': 3.267314702308627, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '3471370', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1140, 'n_words': 253}