<repo_name>thatlisajones/Survey_Example<file_sep>/app/models/feelings.js
var feelings = [
  {
    "feeling_id": 1,
    "feeling_group": "Joy",
    "feeling_name":"Excited",
    "feeling_emoji":"&#x1F601",
    "feeling_color":"#ADFF2F",
    "feeling_def": "Enthusiastic and eager",
    "feeling_value":101
  },
  {
    "feeling_id": 2,
    "feeling_group": "Joy",
    "feeling_name":"Sensuous",
    "feeling_emoji":"&#x1F60F",
    "feeling_color":"#006400",
    "feeling_def": "Physically attractive or attracted",
    "feeling_value":102
    
  },
  {
    "feeling_id": 3,
    "feeling_group": "Joy",
    "feeling_name":"Energetic",
    "feeling_emoji":"&#x1F92A",
    "feeling_color":"#228B22",
    "feeling_def": "Showing great activity or vitality",
    "feeling_value":103
    
  },
  {
    "feeling_id": 4,
    "feeling_group": "Joy",
    "feeling_name":"Cheerful",
    "feeling_emoji":"&#x1F31E",
    "feeling_color":"#00FF00",
    "feeling_def": "Noticeably happy or optimistic",
    "feeling_value":104
  },
  {
    "feeling_id": 5,
    "feeling_group": "Joy",
    "feeling_name":"Creative",
    "feeling_emoji":"&#x1F58C",
    "feeling_color":"#32CD32",
    "feeling_def": "Full of desire to express imagination or ideas",
    "feeling_value":105
  },
  {
    "feeling_id": 6,
    "feeling_group": "Joy",
    "feeling_name":"Hopeful",
    "feeling_emoji":"&#x1F91E",
    "feeling_color":"#7CFC00",
    "feeling_def": "Feeling or inspiring optimism about the future",
    "feeling_value":106
  },
  {
    "feeling_id": 7,
    "feeling_group": "Joy",
    "feeling_name":"Adventurous",
    "feeling_emoji":"&#x1F343",
    "feeling_color":"#6B8E23",
    "feeling_def": "Willing to take risks and try new things",
    "feeling_value":107
  },
  {
    "feeling_id": 8,
    "feeling_group": "Joy",
    "feeling_name":"Fascinated",
    "feeling_emoji":"&#x1F9D0",
    "feeling_color":"#5DBF40",
    "feeling_def": "Strongly attracted or interested",
    "feeling_value":108
  },
  {
    "feeling_id": 9,
    "feeling_group": "Joy",
    "feeling_name":"Stimulated",
    "feeling_emoji":"&#x1F61C",
    "feeling_color":"#17FF0F",
    "feeling_def": "Strongly motivated or invigorated",
    "feeling_value":109
  },
  {
    "feeling_id": 10,
    "feeling_group": "Joy",
    "feeling_name":"Helpful",
    "feeling_emoji":"&#x1F91D",
    "feeling_color":"#98FB98",
    "feeling_def": "Useful or wanting to be useful to others",
    "feeling_value":110
  },
  {
    "feeling_id": 11,
    "feeling_group": "Joy",
    "feeling_name":"Playful",
    "feeling_emoji":"&#x1F33C",
    "feeling_color":"#8AFFA5",
    "feeling_def": "Lighthearted and full of amusement",
    "feeling_value":111
  },
  {
    "feeling_id": 12,
    "feeling_group": "Joy",
    "feeling_name":"Delighted",
    "feeling_emoji":"&#x1F917",
    "feeling_color":"#00A300",
    "feeling_def": "Feeling or showing great pleasure",
    "feeling_value":112
  },
  {
    "feeling_id": 13,
    "feeling_group": "Peace",
    "feeling_name":"Calm",
    "feeling_emoji":"&#x1F60C",
    "feeling_color":"#4B0082",
    "feeling_def": "Free of nervousness or unsettling feelings",
    "feeling_value":201
  },
  {
    "feeling_id": 14,
    "feeling_group": "Peace",
    "feeling_name":"Fulfilled",
    "feeling_emoji":"&#x1F64C",
    "feeling_color":"#8B008B",
    "feeling_def": "Satisfied because of fully developing one's abilities or character",
    "feeling_value":202
  },
  {
    "feeling_id": 15,
    "feeling_group": "Peace",
    "feeling_name":"Meditative",
    "feeling_emoji":"&#x1F334",
    "feeling_color":"#9932CC",
    "feeling_def": "Absorbed in contemplation or careful thought",
    "feeling_value":203
  },
  {
    "feeling_id": 16,
    "feeling_group": "Peace",
    "feeling_name":"Harmonious",
    "feeling_emoji":"&#x262E",
    "feeling_color":"#9400D3",
    "feeling_def": "Feeling part of a pleasing or consistent whole",
    "feeling_value":204
  },
  {
    "feeling_id": 17,
    "feeling_group": "Peace",
    "feeling_name":"Loving",
    "feeling_emoji":"&#x1F49D",
    "feeling_color":"#8A2BE2",
    "feeling_def": "Feeling or showing great care",
    "feeling_value":205
  },
  {
    "feeling_id": 18,
    "feeling_group": "Peace",
    "feeling_name":"Trusting",
    "feeling_emoji":"&#x1F932",
    "feeling_color":"#9370DB",
    "feeling_def": "Feeling a belief in honesty or sincerity; not suspicious",
    "feeling_value":206
  },
  {
    "feeling_id": 19,
    "feeling_group": "Peace",
    "feeling_name":"Nurturing",
    "feeling_emoji":"&#x1F431",
    "feeling_color":"#BA55D3",
    "feeling_def": "Cherishing or encouraging growth or development",
    "feeling_value":207
  },
  {
    "feeling_id": 20,
    "feeling_group": "Peace",
    "feeling_name":"Kind",
    "feeling_emoji":"&#x1F46D",
    "feeling_color":"#FF00FF",
    "feeling_def": "Feeling friendly and considerate",
    "feeling_value":208
  },
  {
    "feeling_id": 21,
    "feeling_group": "Peace",
    "feeling_name":"Validated",
    "feeling_emoji":"&#x2705",
    "feeling_color":"#DA70D6",
    "feeling_def": "Feeling supported or affirmed",
    "feeling_value":209
  },
  {
    "feeling_id": 22,
    "feeling_group": "Peace",
    "feeling_name":"Generous",
    "feeling_emoji":"&#x1F49C",
    "feeling_color":"#EE82EE",
    "feeling_def": "Ready to give more than necessary or expected",
    "feeling_value":210
  },
  {
    "feeling_id": 23,
    "feeling_group": "Peace",
    "feeling_name":"Secure",
    "feeling_emoji":"&#x1F510",
    "feeling_color":"#DDA0DD",
    "feeling_def": "Feeling safe, stable, and free from fear or worry",
    "feeling_value":211
  },
  {
    "feeling_id": 24,
    "feeling_group": "Peace",
    "feeling_name":"Thankful",
    "feeling_emoji":"&#x1F64F",
    "feeling_color":"#E6E6FA",
    "feeling_def": "Feeling gratitude and relief",
    "feeling_value":212
  },
  {
    "feeling_id": 25,
    "feeling_group": "Confidence",
    "feeling_name":"Loyal",
    "feeling_emoji":"&#x1F496",
    "feeling_color":"#F0F8FF",
    "feeling_def": "Giving or showing firm and constant support or allegiance",
    "feeling_value":301
  },
  {
    "feeling_id": 26,
    "feeling_group": "Confidence",
    "feeling_name":"Needed",
    "feeling_emoji":"&#x1F436",
    "feeling_color":"#B0E0E6",
    "feeling_def": "Feeling essential or necessary",
    "feeling_value":302
  },
  {
    "feeling_id": 27,
    "feeling_group": "Confidence",
    "feeling_name":"Appreciated",
    "feeling_emoji":"&#x1F48E",
    "feeling_color":"#87CEFA",
    "feeling_def": "Feeling that one's full worth is recognized",
    "feeling_value":303
  },
  {
    "feeling_id": 28,
    "feeling_group": "Confidence",
    "feeling_name":"Respected",
    "feeling_emoji":"&#x1F3C6",
    "feeling_color":"#87CEEB",
    "feeling_def": "Feeling admired for one's abilities, qualities, or achievements",
    "feeling_value":304
  },
  {
    "feeling_id": 29,
    "feeling_group": "Confidence",
    "feeling_name":"Dignified",
    "feeling_emoji":"&#x1F451",
    "feeling_color":"#00BFFF",
    "feeling_def": "Having or showing a composed or serious manner that is worthy of respect",
    "feeling_value":305
  },
  {
    "feeling_id": 30,
    "feeling_group": "Confidence",
    "feeling_name":"Blessed",
    "feeling_emoji":"&#x1F381",
    "feeling_color":"#1E90FF",
    "feeling_def": "Feeling endowed with divine favor and protection",
    "feeling_value":306
  },
  {
    "feeling_id": 31,
    "feeling_group": "Confidence",
    "feeling_name":"Lucky",
    "feeling_emoji":"&#x1F340",
    "feeling_color":"#6495ED",
    "feeling_def": "Feeling favored by chance or fortune",
    "feeling_value":307
  },
  {
    "feeling_id": 32,
    "feeling_group": "Confidence",
    "feeling_name":"Discerning",
    "feeling_emoji":"&#x1F9D0",
    "feeling_color":"#4682B4",
    "feeling_def": "Having or showing good judgement",
    "feeling_value":308
  },
  {
    "feeling_id": 33,
    "feeling_group": "Confidence",
    "feeling_name":"Loved",
    "feeling_emoji":"&#x1F60D",
    "feeling_color":"#7B68EE",
    "feeling_def": "Feeling deeply cared for",
    "feeling_value":309
  },
  {
    "feeling_id": 34,
    "feeling_group": "Confidence",
    "feeling_name":"Admirable",
    "feeling_emoji":"&#x1F607",
    "feeling_color":"#6A5ACD",
    "feeling_def": "Deserving of respect or approval",
    "feeling_value":310
  },
  {
    "feeling_id": 35,
    "feeling_group": "Confidence",
    "feeling_name":"Successful",
    "feeling_emoji":"&#x1F947",
    "feeling_color":"#4169E1",
    "feeling_def": "Feeling of accomplishment or achievement",
    "feeling_value":311
  },
  {
    "feeling_id": 36,
    "feeling_group": "Confidence",
    "feeling_name":"Deserving",
    "feeling_emoji":"&#x1F4AF",
    "feeling_color":"#0000CD",
    "feeling_def": "Feeling worthy of good treatment or assistance",
    "feeling_value":312
  },
  {
    "feeling_id": 37,
    "feeling_group": "Sadness",
    "feeling_name":"Sorry",
    "feeling_emoji":"&#x1F630",
    "feeling_color":"#FF4500",
    "feeling_def": "Feeling regret or distress, especially through sympathy with someone else.",
    "feeling_value":401
  },
  {
    "feeling_id": 38,
    "feeling_group": "Sadness",
    "feeling_name":"Stupid",
    "feeling_emoji":"&#x1F92F",
    "feeling_color":"#F7A036",
    "feeling_def": "Feeling annoyed or inadequate due to one's mistakes or lack of sense",
    "feeling_value":402
  },
  {
    "feeling_id": 39,
    "feeling_group": "Sadness",
    "feeling_name":"Inferior",
    "feeling_emoji":"&#x1F949",
    "feeling_color":"#F2AC92",
    "feeling_def": "Feeling disadvantaged, less-than, or of lower status",
    "feeling_value":403
  },
  {
    "feeling_id": 40,
    "feeling_group": "Sadness",
    "feeling_name":"Isolated",
    "feeling_emoji":"&#x1F614",
    "feeling_color":"#DAB68B",
    "feeling_def": "Having minimal contact or little in common with others",
    "feeling_value":404
  },
  {
    "feeling_id": 41,
    "feeling_group": "Sadness",
    "feeling_name":"Uninterested",
    "feeling_emoji":"&#x1F4A4",
    "feeling_color":"#E6830A",
    "feeling_def": "Not caring about something or someone",
    "feeling_value":405
  },
  {
    "feeling_id": 42,
    "feeling_group": "Sadness",
    "feeling_name":"Disappointed",
    "feeling_emoji":"&#x1F61E",
    "feeling_color":"#FFD8A8",
    "feeling_def": "Unhappy because someone or something did not fulfill one's hopes or expectations",
    "feeling_value":406
  },
  {
    "feeling_id": 43,
    "feeling_group": "Sadness",
    "feeling_name":"Guilty",
    "feeling_emoji":"&#x2623",
    "feeling_color":"#FF8C00",
    "feeling_def": "Feeling responsible for wrongdoing",
    "feeling_value":407
  },
  {
    "feeling_id": 44,
    "feeling_group": "Sadness",
    "feeling_name":"Ashamed",
    "feeling_emoji":"&#x1F613",
    "feeling_color":"#FF6347",
    "feeling_def": " Feeling embarrassed or guilty because of one's actions, characteristics, or associations",
    "feeling_value":408
  },
  {
    "feeling_id": 45,
    "feeling_group": "Sadness",
    "feeling_name":"Depressed",
    "feeling_emoji":"&#x1F62D",
    "feeling_color":"#FFD4CC",
    "feeling_def": "Feeling general unhappiness or despondency",
    "feeling_value":409
  },
  {
    "feeling_id": 46,
    "feeling_group": "Sadness",
    "feeling_name":"Lonely",
    "feeling_emoji":"&#x1F940",
    "feeling_color":"#F4AC9F",
    "feeling_def": "Feeling sad because one has no friends or company",
    "feeling_value":410
  },
  {
    "feeling_id": 47,
    "feeling_group": "Sadness",
    "feeling_name":"Bored",
    "feeling_emoji":"&#x1F417",
    "feeling_color":"#FF7F50",
    "feeling_def": "Feeling weary because one is unoccupied or lacks interest in one's current activity",
    "feeling_value":411
  },
  {
    "feeling_id": 48,
    "feeling_group": "Sadness",
    "feeling_name":"Tired",
    "feeling_emoji":"&#x1F634",
    "feeling_color":"#FFCEBD",
    "feeling_def": "In need of sleep or rest",
    "feeling_value":412
  },
  {
    "feeling_id": 49,
    "feeling_group": "Anger",
    "feeling_name":"Critical",
    "feeling_emoji":"&#x1F50D",
    "feeling_color":"#FF6347",
    "feeling_def": "Expressing adverse or disapproving comments or judgments",
    "feeling_value":501
  },
  {
    "feeling_id": 50,
    "feeling_group": "Anger",
    "feeling_name":"Spiteful",
    "feeling_emoji":"&#x1F612",
    "feeling_color":"#FF4500",
    "feeling_def": "Feeling malice or nastiness toward someone or something",
    "feeling_value":502
  },
  {
    "feeling_id": 51,
    "feeling_group": "Anger",
    "feeling_name":"Outraged",
    "feeling_emoji":"&#x1F92C",
    "feeling_color":"#8B0000",
    "feeling_def": "Fierce anger, shock, or indignation",
    "feeling_value":503
  },
  {
    "feeling_id": 52,
    "feeling_group": "Anger",
    "feeling_name":"Bitter",
    "feeling_emoji":"&#x2639",
    "feeling_color":"#B22222",
    "feeling_def": "Angry, hurt, or resentful because of one's bad experiences or a sense of unjust treatment",
    "feeling_value":504
  },
  {
    "feeling_id": 53,
    "feeling_group": "Anger",
    "feeling_name":"Resentful",
    "feeling_emoji":"&#x1F624",
    "feeling_color":"#DC143C",
    "feeling_def": "Feeling aggrieved at having been treated unfairly",
    "feeling_value":505
  },
  {
    "feeling_id": 54,
    "feeling_group": "Anger",
    "feeling_name":"Hurt",
    "feeling_emoji":"&#x1F622",
    "feeling_color":"#CD5C5C",
    "feeling_def": "Feeling mental pain or distress",
    "feeling_value":506
  },
  {
    "feeling_id": 55,
    "feeling_group": "Anger",
    "feeling_name":"Skeptical",
    "feeling_emoji":"&#x1F928",
    "feeling_color":"#F08080",
    "feeling_def": "Not easily convinced; having doubts or reservations",
    "feeling_value":507
  },
  {
    "feeling_id": 56,
    "feeling_group": "Anger",
    "feeling_name":"Irritated",
    "feeling_emoji":"&#x1F616",
    "feeling_color":"#E9967A",
    "feeling_def": "Feeling slight anger or annoyance",
    "feeling_value":508
  },
  {
    "feeling_id": 57,
    "feeling_group": "Anger",
    "feeling_name":"Frustrated",
    "feeling_emoji":"&#x1F623",
    "feeling_color":"#990000",
    "feeling_def": "Feeling or expressing distress and annoyance, especially because of inability to change or achieve something",
    "feeling_value":509
  },
  {
    "feeling_id": 58,
    "feeling_group": "Anger",
    "feeling_name":"Dismissive",
    "feeling_emoji":"&#x1F644",
    "feeling_color":"#FFADAD",
    "feeling_def": "Feeling or showing that something is unworthy of consideration",
    "feeling_value":510
  },
  {
    "feeling_id": 59,
    "feeling_group": "Anger",
    "feeling_name":"Distant",
    "feeling_emoji":"&#x1F3D4",
    "feeling_color":"#FA8072",
    "feeling_def": "Not intimate; cool or reserved",
    "feeling_value":511
  },
  {
    "feeling_id": 60,
    "feeling_group": "Anger",
    "feeling_name":"Jealous",
    "feeling_emoji":"&#x1F620",
    "feeling_color":"#8B0000",
    "feeling_def": "Feeling envy of someone or their achievements and advantages; feeling suspicion of someone's unfaithfulness in a relationship",
    "feeling_value":512
  },
  {
    "feeling_id": 61,
    "feeling_group": "Fear",
    "feeling_name":"Confused",
    "feeling_emoji":"&#x1F615",
    "feeling_color":"#FFFFCC",
    "feeling_def": "Feeling bewildered or unable to understand",
    "feeling_value":601
  },
  {
    "feeling_id": 62,
    "feeling_group": "Fear",
    "feeling_name":"Rejected",
    "feeling_emoji":"&#x274C",
    "feeling_color":"#FFFF99",
    "feeling_def": "Feeling dismissed as inadequate, inappropriate, or not preferred.",
    "feeling_value":602
  },
  {
    "feeling_id": 63,
    "feeling_group": "Fear",
    "feeling_name":"Helpless",
    "feeling_emoji":"&#x1F937",
    "feeling_color":"#FFFF66",
    "feeling_def": "Unable to defend oneself or to act without help",
    "feeling_value":603
  },
  {
    "feeling_id": 64,
    "feeling_group": "Fear",
    "feeling_name":"Belittled",
    "feeling_emoji":"&#x1F632",
    "feeling_color":"#FFFF33",
    "feeling_def": "Feeling trivialized or downgraded by someone else",
    "feeling_value":604
  },
  {
    "feeling_id": 65,
    "feeling_group": "Fear",
    "feeling_name":"Insecure",
    "feeling_emoji":"&#x1F633",
    "feeling_color":"#FFFF00",
    "feeling_def": "Not confident or assured; uncertain and anxious",
    "feeling_value":605
  },
  {
    "feeling_id": 66,
    "feeling_group": "Fear",
    "feeling_name":"Anxious",
    "feeling_emoji":"&#x1F630",
    "feeling_color":"#FFFFE0",
    "feeling_def": "Worry, unease, or nervousness, typically about an imminent event or something with an uncertain outcome",
    "feeling_value":606
  },
  {
    "feeling_id": 67,
    "feeling_group": "Fear",
    "feeling_name":"Overwhelmed",
    "feeling_emoji":"&#x1F30B",
    "feeling_color":"#FFFACD",
    "feeling_def": "Engulfed, defeated, or paralyzed by too much feeling",
    "feeling_value":607
  },
  {
    "feeling_id": 68,
    "feeling_group": "Fear",
    "feeling_name":"Embarrassed",
    "feeling_emoji":"&#x1F92D",
    "feeling_color":"#EEE8AA",
    "feeling_def": "Feeling awkward, self-conscious, or ashamed",
    "feeling_value":608
  },
  {
    "feeling_id": 69,
    "feeling_group": "Fear",
    "feeling_name":"Inadequate",
    "feeling_emoji":"&#x2B55",
    "feeling_color":"#FAFAD2",
    "feeling_def": "Feeling unable to deal with a situation or with life",
    "feeling_value":609
  },
  {
    "feeling_id": 70,
    "feeling_group": "Fear",
    "feeling_name":"Insignificant",
    "feeling_emoji":"&#x1F400",
    "feeling_color":"#CCCC00",
    "feeling_def": "Feeling too small or unimportant to be worth consideration",
    "feeling_value":610
  },
  {
    "feeling_id": 71,
    "feeling_group": "Fear",
    "feeling_name":"Discouraged",
    "feeling_emoji":"&#x1F61F",
    "feeling_color":"#F0F093",
    "feeling_def": "Having lost confidence or enthusiasm; disheartened",
    "feeling_value":611
  },
  {
    "feeling_id": 72,
    "feeling_group": "Fear",
    "feeling_name":"Frightened",
    "feeling_emoji":"&#x1F631",
    "feeling_color":"#FFFF85",
    "feeling_def": "Feeling deterred from involvement or action; strong fear or anxiety.",
    "feeling_value":612
  }
  ]
  
  module.exports = feelings;
<file_sep>/app/routing/apiRoutes.js
// var feelingsData = require("../data/feelings");
// //GET route for url /api/feelings -- displays a JSON of all possible feelings

// module.exports = function(app) {
//     app.get("/api/feelings", function(req, res) {
//         return res.json(feelingsData);
//     });
//     //POST route /api/feelings -- handles incoming survey results and compatibility logic
//     app.post("/api/feelings", function(req, res) {
//         var newfeeling = req.body;

//         console.log(newfeeling);

//         //add code for the feeling matching based on new feeling details
//         newfeeling.routeName = newfeeling.name.replace(/\s+/g, "").toLowerCase();
//         console.log(`${newfeeling.name} has been added to Fakefeeling Finder.`);
//         feelings.push(newfeeling);
//         res.json(newfeeling);
//     })};
var feelings = require("../data/feelings");

module.exports = function(app) {
  // Return all feelings found in feelings.js as JSON
  app.get("/api/feelings", function(req, res) {
    res.json(feelings);
  });

  app.post("/api/feelings", function(req, res) {
    console.log("req.body: ", req.body);
    console.log("body of post questions: ",req.body.questions);

    // Receive user details (name, photo, questions)
    var user = req.body;

    // parseInt for questions
    for(var i = 0; i < user.questions.length; i++) {
      user.questions[i] = parseInt(user.questions[i]);
    }

    // default feeling match is the first feeling but result will be whoever has the minimum difference in questions
    var compatibilityValue = 0;
    var minimumDifference = 40;

    // in this for-loop, start off with a zero difference and compare the user and the ith feeling questions, one set at a time
    //  whatever the difference is, add to the total difference
    for(var i = 0; i < feelings.length; i++) {
      var totalDifference = 0;
      for(var j = 0; j < feelings[i].questions.length; j++) {
        var difference = Math.abs(user.questions[j] - feelings[i].questions[j]);
        totalDifference += difference;
      }

      // if there is a new minimum, change the best feeling index and set the new minimum for next iteration comparisons
      if(totalDifference < minimumDifference) {
        compatibilityValue = i;
        minimumDifference = totalDifference;
      }
    }

    // after finding match, add user to feeling array
    feelings.push(user);

    // send back to browser the best feeling match
    res.json(feelings[compatibilityValue]);
  });
};