'use strict';

var a11y = require('./lib/a11y');
var cssStats = require('./lib/css-stats');
var pageSpeed = require('./lib/page-speed');

var humanizeUrl = require('humanize-url');
var normalizeUrl = require('normalize-url');

module.exports = function scrutinize(url, options, callback) {
  if (typeof url != 'string') {
    throw new TypeError('scrutinize expects a url');
  }

  options = options || {};
  options.verbose = options.verbose || false;
  options.key = options.key || process.env.GAPPS_API_KEY;
  options.url = { url: url };

  callback = callback || function() {};

  options.url.normalizedUrl = normalizeUrl(url);
  options.url.humanizedUrl = humanizeUrl(url);

  pageSpeed(options.url, options, {})
    .then(function(data) {
      return a11y(options.url, data);
    })
    .then(function(data) {
      return cssStats(options.url, data);
    }).then(function(data) {
      callback(data);
    }).catch(function(error) {
      console.log(error);
    });
}

@@ -460,14 +460,36 @@
 ons.
-key = 
+url = %7B url: url %7D;%0A%0A  if (!
 opti
@@ -496,18 +496,18 @@
 ons.key 
-%7C%7C
+&&
  process
@@ -524,18 +524,22 @@
 _API_KEY
-;%0A
+) %7B%0A  
   option
@@ -540,35 +540,52 @@
 options.
-url = %7B url: url
+key = process.env.GAPPS_API_KEY;%0A 
  %7D
-;
 %0A%0A  call

Handle a lack of key more elegantly