"use strict";

let localMode = process.env.LAMBDA_TASK_ROOT ? false : true;

// Local settings
let d = 3; // Depth
for (var i = 1; i <= d; i++) {
	try {
		global.blackoutUserSettings = require('../'.repeat(i) + '.user.json');
	} catch (err) {
		// A local settings file must not exist
	}
}

const API = require('./index');
let payload = JSON.parse(process.argv[2]);
let timeout = blackoutUserSettings._redis && localMode && blackoutUserSettings.localRRTimeout ? blackoutUserSettings.localRRTimeout : blackoutUserSettings.localTimeout ? blackoutUserSettings.localTimeout : 7000;
let timeoutId;

API.handler(payload, null, (err, payload) => {
	if (err) {
		throw err;
	} else {
		let log = console._log ? console._log : console.log;
		log('--payload--');
		log(JSON.stringify(payload));
		log('--endpayload--');
	}
	clearTimeout(timeoutId);
});

timeoutId = setTimeout(() => {
	console.log("\n-------- PROCESS TIMED OUT! --------\n");
	process.exit(1);
}, timeout);
//# sourceMappingURL=local.js.map