-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
127 lines (109 loc) · 3.69 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// *****************************************************************************
// Server.js - This file is the initial starting point for the Node/Express server.
//
// ******************************************************************************
// *** Dependencies
// =============================================================
var db = require("./models");
var express = require("express");
var bodyParser = require("body-parser");
// Sets up the Express App
// =============================================================
var app = express();
var PORT = process.env.PORT || 8080;
// Sets up the Express app to handle data parsing
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.text());
app.use(bodyParser.json({ type: "application/vnd.api+json" }));
// Static directory
app.use(express.static("public"));
// Routes
// =============================================================
require("./routes/api-routes.js")(app);
require("./routes/html-routes.js")(app);
// Syncing our sequelize models and then starting our Express app
// =============================================================
// Preloaded questions:
db.sequelize.sync({ force: true }).then(function() {
db.Questions.create({
question_text: "Smallest United States by Land Mass",
choiceOne: "Rhode Island",
choiceTwo: "Delaware",
choiceThree: "Connecticut",
choiceFour: "New Jersey",
choiceFive: "New Hampshire",
question_category: "Category 1",
user_score: 0,
disclaimer: "N/A"
})
db.Questions.create({
question_text: "Largest Militaries in the World (by Expenditure)",
choiceOne: "United States",
choiceTwo: "China",
choiceThree: "Saudi Arabia",
choiceFour: "United Kingdom (Britain)",
choiceFive: "Russia",
question_category: "Category 1",
user_score: 0,
disclaimer: "Based of national military budgets of 2015"
})
db.Questions.create({
question_text: "Busiest Airports in the United States",
choiceOne: "Hartsfield-Jackson (Atlanta)",
choiceTwo: "Los Angeles International",
choiceThree: "O'Hare International (Chicago)",
choiceFour: "Dallas/Fortworth International",
choiceFive: "JFK International (NYC)",
question_category: "Category 1",
user_score: 0,
disclaimer: "Data from 2015, total number of passengers enplaned and deplaned."
})
db.Questions.create({
question_text: "Highest Grossing Movies (Inflation Unadjusted)",
choiceOne: "Avatar",
choiceTwo: "Titanic",
choiceThree: "Star Wars: The Force Awakens",
choiceFour: "Jurassic World",
choiceFive: "The Avengers",
question_category: "Category 1",
user_score: 0,
disclaimer: "From May, 2017. Total worldwide Gross"
})
db.Questions.create({
question_text: "Most Populated Countries",
choiceOne: "China",
choiceTwo: "India",
choiceThree: "United States",
choiceFour: "Indonesia",
choiceFive: "Brazil",
question_category: "Category 1",
user_score: 0,
disclaimer: "Includes territories - As of June, 2017"
})
db.Questions.create({
question_text: "Restaurant Chains with Most Locations",
choiceOne: "Subway",
choiceTwo: "McDonald's",
choiceThree: "Starbucks",
choiceFour: "Pizza Hut",
choiceFive: "Burger King",
question_category: "Category 1",
user_score: 0,
disclaimer: "Worldwide as of 2016."
})
db.Questions.create({
question_text: "NBA Player with Most MVP Awards",
choiceOne: "Kareem Abdul-Jabbar",
choiceTwo: "Bill Russell",
choiceThree: "Michael Jordan",
choiceFour: "Wilt Chamberlain",
choiceFive: "Lebron James",
question_category: "Category 1",
user_score: 0,
disclaimer: "Regular season only - Ties broken by first to accomplish."
})
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});
});