bin/serve.js
function serveRemoteJson(request, response, next) {
	if (request.path !== '/remote') {
		return next();
	}
	var options = {
		url: request.query.url,
		headers: request.query.headers
	};
	var error;

	if (!options.url || typeof options.url !== 'string') {
		error = new Error('Invalid query parameter: url');
		error.status = 400;
		return next(error);
	}

	if (options.headers && typeof options.headers !== 'string') {
		error = new Error('Invalid query parameter: headers');
		error.status = 400;
		return next(error);
	}

	options.headers = parseHeaders(options.headers);

	loadRemoteJson(options, function (error, json) {
		if (error) {
			return next(error);
		}
		response.writeHead(200, {
			'Content-Type': 'application/x-shunter+json'
		});
		response.end(JSON.stringify(json, null, 4));
	});
}
function serveRemoteJson(request, response, next) {
	if (request.path !== '/remote') {
		return next();
	}
	var options = {
		url: request.query.url,
		headers: request.query.headers
	};
	var error;

	if (!options.url || typeof options.url !== 'string') {
		error = new Error('Invalid query parameter: url');
		error.status = 400;
		return next(error);
	}

	if (options.headers && typeof options.headers !== 'string') {
		error = new Error('Invalid query parameter: headers');
		error.status = 400;
		return next(error);
	}

	options.headers = parseHeaders(options.headers);

	loadRemoteJson(options, function (error, json) {
		if (error) {
			return next(error);
		}
		response.writeHead(200, {
			'Content-Type': 'application/x-shunter+json'
		});
		response.end(JSON.stringify(json, null, 4));
	});
}
function serveRemoteJson ( request , response , next ) { if ( request . path !== '/remote' ) { return next ( ) ; } var options = { url : request . query . url , headers : request . query . headers } ; var error ; if ( ! options . url || typeof options . url !== 'string' ) { error = new Error ( 'Invalid query parameter: url' ) ; error . status = 400 ; return next ( error ) ; } if ( options . headers && typeof options . headers !== 'string' ) { error = new Error ( 'Invalid query parameter: headers' ) ; error . status = 400 ; return next ( error ) ; } options . headers = parseHeaders ( options . headers ) ; loadRemoteJson ( options , function ( error , json ) { if ( error ) { return next ( error ) ; } response . writeHead ( 200 , { 'Content-Type' : 'application/x-shunter+json' } ) ; response . end ( JSON . stringify ( json , null , 4 ) ) ; } ) ; }
Middleware to serve remote JSON
Middleware to serve remote JSON