Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hey there, sailor... #6

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

node_modules/
<<<<<<< HEAD
config/config.json/
=======
config/config.json
>>>>>>> 286893e8866e559129d17ce24cf945fbc606e131

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# assignment_okodin
Build a dating app so Viking thunder gods can find love &lt;3

Dan and Will


Binary file added Static/darkelf.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Static/frostGiant.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
53 changes: 53 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const express = require("express");
const app = express();

// Templates
const expressHandlebars = require("express-handlebars");
const hbs = expressHandlebars.create({
partialsDir: "views/",
defaultLayout: "application",
helpers: require("./helpers")
});
app.engine("handlebars", hbs.engine);
app.set("view engine", "handlebars");

// Session
app.use(
require("cookie-session")({
name: "session",
keys: ["xBR44RmMaZvYRwOkE26T"]
})
);

// Flash
app.use(require("express-flash-messages")());

// Post Data
const bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({ extended: true }));

// Log Request Info
const morgan = require("morgan");
const morganToolkit = require("morgan-toolkit")(morgan);
app.use(morganToolkit());

// Method Overriding
const methodOverride = require("method-override");
const getPostSupport = require("express-method-override-get-post-support");
app.use(methodOverride(getPostSupport.callback, getPostSupport.options));

// Routes
app.use("/", require("./routers/account"));
app.use("/users", require("./routers/users"));
// Set up port/host
const port = process.env.PORT || process.argv[2] || 3000;
const host = "localhost";
let args = process.env.NODE_ENV === "production" ? [port] : [port, host];

// helpful log when the server starts
args.push(() => {
console.log(`Listening: http://${host}:${port}`);
});

// Use apply to pass the args to listen
app.listen.apply(app, args);
11 changes: 11 additions & 0 deletions helpers/FlashHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const FlashHelper = {};
FlashHelper.bootstrapAlertClassFor = function(key) {
return (
{
error: "danger",
alert: "danger",
notice: "info"
}[key] || key
);
};
module.exports = FlashHelper;
7 changes: 7 additions & 0 deletions helpers/UsersHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
usersPath: () => "/users",
userPath: id => `/users/${id}`,
newUserPath: () => "/register",
editUserPath: id => `/users/${id}/edit`,
destroyUserPath: id => `/users/${id}/?_method=delete`
};
5 changes: 5 additions & 0 deletions helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const LoadHelpers = require("load-helpers");
const helperLoader = new LoadHelpers();
const helpers = helperLoader.load("helpers/*Helper.js").cache;

module.exports = helpers;
42 changes: 42 additions & 0 deletions migrations/20170807170256-create-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"use strict";
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface
.createTable("Users", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
ProfileId: {
allowNull: true,
type: Sequelize.INTEGER
},
loggedIn: {
allowNull: false,
type: Sequelize.BOOLEAN,
defaultValue: false
},
username: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
}
})
.then(() => {
return queryInterface.addIndex("Users", ["username"], { unique: true });
});
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable("Users");
}
};
65 changes: 65 additions & 0 deletions migrations/20170807214209-create-profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"use strict";
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.createTable("Profiles", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.STRING
},
UserId: {
type: Sequelize.INTEGER
},
PictureId: {
type: Sequelize.INTEGER
},
ProfileLocationId: {
type: Sequelize.INTEGER
},
TalentsId: {
type: Sequelize.INTEGER
},
FavoriteThingsId: {
type: Sequelize.INTEGER
},
email: {
type: Sequelize.STRING
},
age: {
type: Sequelize.INTEGER
},
gender: {
type: Sequelize.STRING
},
maritalStatus: {
type: Sequelize.BOOLEAN
},
kids: {
type: Sequelize.INTEGER
},
aboutMe: {
type: Sequelize.TEXT
},
whyMsgMe: {
type: Sequelize.TEXT
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
}
});
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable("Profiles");
}
};
29 changes: 29 additions & 0 deletions migrations/20170807214406-create-pictures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.createTable("Pictures", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
fileName: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
}
});
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable("Pictures");
}
};
29 changes: 29 additions & 0 deletions migrations/20170807214445-create-picture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.createTable("Pictures", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
fileName: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
}
});
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable("Pictures");
}
};
32 changes: 32 additions & 0 deletions migrations/20170807214558-create-talent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.createTable("Talents", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
ProfileId: {
type: Sequelize.INTEGER
},
ActivityId: {
type: Sequelize.INTEGER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
}
});
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable("Talents");
}
};
32 changes: 32 additions & 0 deletions migrations/20170807214621-create-favorite-things.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.createTable("FavoriteThings", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
ProfileId: {
type: Sequelize.INTEGER
},
ActivityId: {
type: Sequelize.INTEGER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
}
});
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable("FavoriteThings");
}
};
32 changes: 32 additions & 0 deletions migrations/20170807214632-create-favorite-thing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.createTable("FavoriteThings", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
ProfileId: {
type: Sequelize.INTEGER
},
ActivityId: {
type: Sequelize.INTEGER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
}
});
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable("FavoriteThings");
}
};
32 changes: 32 additions & 0 deletions migrations/20170807214707-create-location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.createTable("Locations", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
ProfileId: {
type: Sequelize.INTEGER
},
CityId: {
type: Sequelize.INTEGER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.fn("NOW")
}
});
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable("Locations");
}
};
Loading