// this will pull data using the STEAM API and display it as JSON on a web server
// using the callback info if a new hero is added since the last time the server is
// refreshed it will update with a simple page refresh

// sets up the modules
var Steam = require('steam-webapi');
var express = require('express');

// sets your key to var
var steamAPIKey = "84E02F1B45E5C2655871C427A03D9883";

var app = express(); // creates server

Steam.ready(steamAPIKey, function(err) {
    if (err) return console.log(err);

    var steam = new Steam({key: steamAPIKey});

    // Retrieve the steam ID from a steam username/communityID
    steam.resolveVanityURL({vanityurl:'howdoiskill'}, function(err, data) {
        // data -> { steamid: '76561197968620915', success: 1 }
        var metadataArray = []; // initializes the array
        console.log(data);

        // sets the game ID to Dota2
        data.gameid = Steam.DOTA2;

        // gets heroes from Dota2
        steam.getHeroes(data, function (err, data) {
            console.log(data);  // {heroes: [ {name: 'npc_dota_hero_antimage', id:1} ... ]}

            // this array will be manipulatable by calling an index and then a property
            metadataArray.push(data); // sends it to an array so the JSON can be displayed on the page/used easier


        }); // end of steam.getHeroes

        app.get('/', function(req, res){
          res.send(JSON.stringify(data, null, 4)); // sends this to the server
        }); // end of app.get

    }); // end of steam.resolveVanity URL



}); // end of steam.ready






app.listen(8080); // listens to port 8080

@@ -428,17 +428,95 @@
  server%0A
-%0A
+var metadataArray = %5B%5D; // initializes the array%0Afunction getInfo(callback)%7B%0A  
 Steam.re
@@ -544,24 +544,26 @@
 tion(err) %7B%0A
+  
     if (err)
@@ -589,24 +589,26 @@
 (err);%0A%0A    
+  
 var steam = 
@@ -643,16 +643,18 @@
 );%0A%0A    
+ 
+ 
 // Retri
@@ -704,16 +704,18 @@
 unityID%0A
+  
     stea
@@ -790,16 +790,18 @@
         
+  
 // data 
@@ -854,63 +854,8 @@
 %7D%0A  
-      var metadataArray = %5B%5D; // initializes the array%0A
     
@@ -874,24 +874,26 @@
 log(data);%0A%0A
+  
         // s
@@ -913,24 +913,26 @@
 ID to Dota2%0A
+  
         data
@@ -963,16 +963,18 @@
         
+  
 // gets 
@@ -987,24 +987,26 @@
  from Dota2%0A
+  
         stea
@@ -1038,32 +1038,34 @@
 n (err, data) %7B%0A
+  
             cons
@@ -1153,16 +1153,18 @@
         
+  
 // this 
@@ -1231,16 +1231,18 @@
 roperty%0A
+  
         
@@ -1349,25 +1349,30 @@
 easier%0A%0A
-%0A
+      
         
 %7D); // e
@@ -1367,47 +1367,85 @@
     
-%7D); // end of steam.getHeroes%0A%0A        
+callback(metadataArray); // adds a callback%0A          %7D);%0A      %7D);%0A  %7D);%0A%7D%0A%0A
 app.
@@ -1475,23 +1475,18 @@
 res)%7B%0A  
-       
+//
  res.sen
@@ -1502,20 +1502,29 @@
 ringify(
-data
+metadataArray
 , null, 
@@ -1562,111 +1562,92 @@
 r%0A  
-      %7D); // end of app.get%0A%0A    %7D); // end of steam.resolveVanity URL%0A%0A%0A%0A%7D);
+getInfo(function(data)%7B%0A    res.send(data)
  // 
+s
 end
- of steam.ready%0A%0A%0A%0A
+s the data to the server%0A  %7D);%0A%7D);
 %0A%0A%0Aa

Revert "fixes memory issue as well as re-orders somethings."