{"size": 527, "ext": "js", "max_stars_repo_path": "src/route.js", "max_stars_repo_name": "marcdacz/express-api", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/route.js", "max_issues_repo_name": "marcdacz/express-api", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/route.js", "max_forks_repo_name": "marcdacz/express-api", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.0952380952, "max_line_length": 58, "alphanum_fraction": 0.6394686907}
const fs = require('fs');
const path = require('path');

let loadJson = (res, dir, file = "success") => {
	let fileName = path.join(dir, file + '.json');
	let json = JSON.parse(fs.readFileSync(fileName, 'utf8'));
	res.status(200).send(json);
};

exports.getCustomData = (req, res, dir) => {
	let file = 'hasNoCookie';
	const token = req.cookies.myCookie;
	if (['hasCookie', 'hasNoCookie'].includes(token)) {
		file = token;
	}
	loadJson(res, dir, file);
};

exports.getDefaultData = (req, res, dir) => {
	loadJson(res, dir);
};