+
+
BAD and BOUJEE
+
Venues
+
Venues
+
+
+
+
+
+
diff --git a/Archive/app.js b/Archive/app.js
new file mode 100644
index 00000000..98c14d29
--- /dev/null
+++ b/Archive/app.js
@@ -0,0 +1,137 @@
+console.log("Sanity Check: JS is working!");
+var $venuesList;
+var allVenues = [];
+
+$(document).ready(function(){
+
+ $venuesList = $('#venueTarget');
+ $.ajax({
+ method: 'GET',
+ url: '/api/venues',
+ success: handleSuccess,
+ // error: handleError
+ });
+
+ // $('#venue-form').on('submit', function(e) {
+ // e.preventDefault();
+ // $.ajax({
+ // method: 'POST',
+ // url: '/api/venues',
+ // data: $(this).serialize(),
+ // success: newVenueSuccess,
+ // // error: newBookError
+ // });
+ // });
+ //
+ // $venuesList.on('click', '.deleteBtn', function() {
+ // console.log('clicked delete button to', '/api/venues/'+$(this).attr('data-id'));
+ // $.ajax({
+ // method: 'DELETE',
+ // url: '/api/venues/'+$(this).attr('data-id'),
+ // success: deleteVenueSuccess,
+ // // error: deleteBookError
+ // });
+ // });
+
+});
+
+function getVenueHtml(venue) {
+ return `
+
+
+
+
+
+
+
+

+
+
+
+ -
+
+ ${venue.name}
+
+ -
+
Location:
+ ${venue.location}
+
+ -
+
Website:
+ ${venue.website}
+
+ -
+
Notes:
+ ${venue.notes}
+
+
+
+
+
+
+
+
+
+
+ `;
+}
+
+function getAllVenuesHtml(venues) {
+ return venues.map(getVenueHtml).join("");
+}
+
+// helper function to render all posts to view
+// note: we empty and re-render the collection each time our post data changes
+function render () {
+ // empty existing posts from view
+ $venuesList.empty();
+
+ // pass `allBooks` into the template function
+ var venuesHtml = getAllVenuesHtml(allVenues);
+
+ // append html to the view
+ $venuesList.append(venuesHtml);
+};
+
+function handleSuccess(json) {
+ allVenues = json;
+ render();
+}
+
+// function handleError(e) {
+// console.log('uh oh');
+// $('#bookTarget').text('Failed to load books, is the server working?');
+// }
+
+function newVenueSuccess(json) {
+ $('#venue-form').val('');
+ allVenues.push(json);
+ render();
+}
+
+// function newBookError() {
+// console.log('newbook error!');
+// }
+
+function deleteVenueSuccess(json) {
+ var venue = json;
+ console.log(json);
+ var venueId = venue._id;
+ console.log('delete venue', venueId);
+ // find the book with the correct ID and remove it from our allBooks array
+ for(var index = 0; index < allVenues.length; index++) {
+ if(allVenues[index]._id === venueId) {
+ allVenues.splice(index, 1);
+ break; // we found our book - no reason to keep searching (this is why we didn't use forEach)
+ }
+ }
+ render();
+}
+
+// function deleteBookError() {
+// console.log('deletebook error!');
+// }
diff --git a/models/campsite.js.example b/models/campsite.js.example
deleted file mode 100644
index cb9e8ee6..00000000
--- a/models/campsite.js.example
+++ /dev/null
@@ -1,10 +0,0 @@
-// var mongoose = require('mongoose'),
-// Schema = mongoose.Schema;
-
-// var CampsiteSchema = new Schema({
-// description: String
-// });
-
-// var Campsite = mongoose.model('Campsite', CampsiteSchema);
-
-// module.exports = Campsite;
diff --git a/models/index.js b/models/index.js
index 66997fe0..15154150 100644
--- a/models/index.js
+++ b/models/index.js
@@ -3,3 +3,6 @@ mongoose.connect( process.env.MONGODB_URI || "mongodb://localhost/personal-api",
mongoose.Promise = global.Promise; // use native Promise
// module.exports.Campsite = require("./campsite.js.example");
+
+module.exports.Venue = require("./venue");
+module.exports.Profile = require("./profile");
diff --git a/models/profile.js b/models/profile.js
new file mode 100644
index 00000000..0cb38270
--- /dev/null
+++ b/models/profile.js
@@ -0,0 +1,21 @@
+var mongoose = require('mongoose'),
+ Schema = mongoose.Schema;
+
+var ProfileSchema = new Schema({
+ name: String,
+ githubUsername: String,
+ githubLink: String,
+ githubProfileImage: String,
+ personalSiteLink: String,
+ currentCity: String,
+ hobbies: [{
+ hobby: String,
+ destOne: String,
+ destTwo: String,
+ destThree: String,
+ }],
+});
+
+var Profile = mongoose.model('Profile', ProfileSchema);
+
+module.exports = Profile;
diff --git a/models/venue.js b/models/venue.js
new file mode 100644
index 00000000..5b77c845
--- /dev/null
+++ b/models/venue.js
@@ -0,0 +1,16 @@
+var mongoose = require('mongoose'),
+ Schema = mongoose.Schema;
+
+//This must match what is in the seed file
+var VenueSchema = new Schema({
+ image: String,
+ name: String,
+ location: String,
+ website: String,
+ notes: String,
+ imageBackground: String,
+});
+
+var Venue = mongoose.model('Venue', VenueSchema);
+
+module.exports = Venue;
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 00000000..a704cdd6
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,575 @@
+{
+ "name": "express-personal-api",
+ "version": "1.0.0",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "accepts": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz",
+ "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=",
+ "requires": {
+ "mime-types": "2.1.16",
+ "negotiator": "0.6.1"
+ }
+ },
+ "array-flatten": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
+ "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
+ },
+ "async": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz",
+ "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=",
+ "requires": {
+ "lodash": "4.17.4"
+ }
+ },
+ "bluebird": {
+ "version": "2.10.2",
+ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.2.tgz",
+ "integrity": "sha1-AkpVFylTCIV/FPkfEQb8O1VfRGs="
+ },
+ "body-parser": {
+ "version": "1.17.2",
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.17.2.tgz",
+ "integrity": "sha1-+IkqvI+eYn1Crtr7yma/WrmRBO4=",
+ "requires": {
+ "bytes": "2.4.0",
+ "content-type": "1.0.2",
+ "debug": "2.6.7",
+ "depd": "1.1.1",
+ "http-errors": "1.6.2",
+ "iconv-lite": "0.4.15",
+ "on-finished": "2.3.0",
+ "qs": "6.4.0",
+ "raw-body": "2.2.0",
+ "type-is": "1.6.15"
+ }
+ },
+ "bson": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.4.tgz",
+ "integrity": "sha1-k8ENOeqltYQVy8QFLz5T5WKwtyw="
+ },
+ "buffer-shims": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz",
+ "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E="
+ },
+ "bytes": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz",
+ "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk="
+ },
+ "content-disposition": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
+ "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ="
+ },
+ "content-type": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz",
+ "integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0="
+ },
+ "cookie": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
+ "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s="
+ },
+ "cookie-signature": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
+ "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
+ },
+ "debug": {
+ "version": "2.6.7",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz",
+ "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=",
+ "requires": {
+ "ms": "2.0.0"
+ }
+ },
+ "depd": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz",
+ "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k="
+ },
+ "destroy": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
+ "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
+ },
+ "ee-first": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
+ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
+ },
+ "encodeurl": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz",
+ "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA="
+ },
+ "es6-promise": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz",
+ "integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q="
+ },
+ "escape-html": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
+ "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
+ },
+ "etag": {
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.0.tgz",
+ "integrity": "sha1-b2Ma7zNtbEY2K1F2QETOIWvjwFE="
+ },
+ "express": {
+ "version": "4.15.4",
+ "resolved": "https://registry.npmjs.org/express/-/express-4.15.4.tgz",
+ "integrity": "sha1-Ay4iU0ic+PzgJma+yj0R7XotrtE=",
+ "requires": {
+ "accepts": "1.3.4",
+ "array-flatten": "1.1.1",
+ "content-disposition": "0.5.2",
+ "content-type": "1.0.2",
+ "cookie": "0.3.1",
+ "cookie-signature": "1.0.6",
+ "debug": "2.6.8",
+ "depd": "1.1.1",
+ "encodeurl": "1.0.1",
+ "escape-html": "1.0.3",
+ "etag": "1.8.0",
+ "finalhandler": "1.0.4",
+ "fresh": "0.5.0",
+ "merge-descriptors": "1.0.1",
+ "methods": "1.1.2",
+ "on-finished": "2.3.0",
+ "parseurl": "1.3.1",
+ "path-to-regexp": "0.1.7",
+ "proxy-addr": "1.1.5",
+ "qs": "6.5.0",
+ "range-parser": "1.2.0",
+ "send": "0.15.4",
+ "serve-static": "1.12.4",
+ "setprototypeof": "1.0.3",
+ "statuses": "1.3.1",
+ "type-is": "1.6.15",
+ "utils-merge": "1.0.0",
+ "vary": "1.1.1"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.6.8",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
+ "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
+ "requires": {
+ "ms": "2.0.0"
+ }
+ },
+ "qs": {
+ "version": "6.5.0",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.0.tgz",
+ "integrity": "sha512-fjVFjW9yhqMhVGwRExCXLhJKrLlkYSaxNWdyc9rmHlrVZbk35YHH312dFd7191uQeXkI3mKLZTIbSvIeFwFemg=="
+ }
+ }
+ },
+ "finalhandler": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.0.4.tgz",
+ "integrity": "sha512-16l/r8RgzlXKmFOhZpHBztvye+lAhC5SU7hXavnerC9UfZqZxxXl3BzL8MhffPT3kF61lj9Oav2LKEzh0ei7tg==",
+ "requires": {
+ "debug": "2.6.8",
+ "encodeurl": "1.0.1",
+ "escape-html": "1.0.3",
+ "on-finished": "2.3.0",
+ "parseurl": "1.3.1",
+ "statuses": "1.3.1",
+ "unpipe": "1.0.0"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.6.8",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
+ "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
+ "requires": {
+ "ms": "2.0.0"
+ }
+ }
+ }
+ },
+ "forwarded": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz",
+ "integrity": "sha1-Ge+YdMSuHCl7zweP3mOgm2aoQ2M="
+ },
+ "fresh": {
+ "version": "0.5.0",
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz",
+ "integrity": "sha1-9HTKXmqSRtb9jglTz6m5yAWvp44="
+ },
+ "hooks-fixed": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.0.tgz",
+ "integrity": "sha1-oB2JTVKsf2WZu7H2PfycQR33DLo="
+ },
+ "http-errors": {
+ "version": "1.6.2",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz",
+ "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=",
+ "requires": {
+ "depd": "1.1.1",
+ "inherits": "2.0.3",
+ "setprototypeof": "1.0.3",
+ "statuses": "1.3.1"
+ }
+ },
+ "iconv-lite": {
+ "version": "0.4.15",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz",
+ "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es="
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
+ },
+ "ipaddr.js": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.4.0.tgz",
+ "integrity": "sha1-KWrKh4qCGBbluF0KKFqZvP9FgvA="
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
+ },
+ "kareem": {
+ "version": "1.5.0",
+ "resolved": "https://registry.npmjs.org/kareem/-/kareem-1.5.0.tgz",
+ "integrity": "sha1-4+QQHZ3P3imXadr0tNtk2JXRdEg="
+ },
+ "lodash": {
+ "version": "4.17.4",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
+ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
+ },
+ "media-typer": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+ "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
+ },
+ "merge-descriptors": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
+ "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
+ },
+ "methods": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
+ "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
+ },
+ "mime": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz",
+ "integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM="
+ },
+ "mime-db": {
+ "version": "1.29.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.29.0.tgz",
+ "integrity": "sha1-SNJtI1WJZRcErFkWygYAGRQmaHg="
+ },
+ "mime-types": {
+ "version": "2.1.16",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.16.tgz",
+ "integrity": "sha1-K4WKUuXs1RbbiXrCvodIeDBpjiM=",
+ "requires": {
+ "mime-db": "1.29.0"
+ }
+ },
+ "mongodb": {
+ "version": "2.2.31",
+ "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.31.tgz",
+ "integrity": "sha1-GUBEXGYeGSF7s7+CRdmFSq71SNs=",
+ "requires": {
+ "es6-promise": "3.2.1",
+ "mongodb-core": "2.1.15",
+ "readable-stream": "2.2.7"
+ }
+ },
+ "mongodb-core": {
+ "version": "2.1.15",
+ "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.15.tgz",
+ "integrity": "sha1-hB9TuH//9MdFgYnDXIroJ+EWl2Q=",
+ "requires": {
+ "bson": "1.0.4",
+ "require_optional": "1.0.1"
+ }
+ },
+ "mongoose": {
+ "version": "4.11.9",
+ "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.11.9.tgz",
+ "integrity": "sha512-4WTZOex1yGVv5lwjEtIQ4DEP9UaYL8wLhhrxrSBC8meU8l/D+r/cBeNfHMmIptWNonIp9gpgvKu3Vk3IkuXDTw==",
+ "requires": {
+ "async": "2.1.4",
+ "bson": "1.0.4",
+ "hooks-fixed": "2.0.0",
+ "kareem": "1.5.0",
+ "mongodb": "2.2.31",
+ "mpath": "0.3.0",
+ "mpromise": "0.5.5",
+ "mquery": "2.3.1",
+ "ms": "2.0.0",
+ "muri": "1.2.2",
+ "regexp-clone": "0.0.1",
+ "sliced": "1.0.1"
+ }
+ },
+ "mpath": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.3.0.tgz",
+ "integrity": "sha1-elj3iem1/TyUUgY0FXlg8mvV70Q="
+ },
+ "mpromise": {
+ "version": "0.5.5",
+ "resolved": "https://registry.npmjs.org/mpromise/-/mpromise-0.5.5.tgz",
+ "integrity": "sha1-9bJCWddjrMIlewoMjG2Gb9UXMuY="
+ },
+ "mquery": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/mquery/-/mquery-2.3.1.tgz",
+ "integrity": "sha1-mrNnSXFIAP8LtTpoHOS8TV8HyHs=",
+ "requires": {
+ "bluebird": "2.10.2",
+ "debug": "2.6.8",
+ "regexp-clone": "0.0.1",
+ "sliced": "0.0.5"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.6.8",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
+ "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
+ "requires": {
+ "ms": "2.0.0"
+ }
+ },
+ "sliced": {
+ "version": "0.0.5",
+ "resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz",
+ "integrity": "sha1-XtwETKTrb3gW1Qui/GPiXY/kcH8="
+ }
+ }
+ },
+ "ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+ },
+ "muri": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/muri/-/muri-1.2.2.tgz",
+ "integrity": "sha1-YxmBMmUNsIoEzHnM0A3Tia/SYxw="
+ },
+ "negotiator": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
+ "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
+ },
+ "on-finished": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
+ "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
+ "requires": {
+ "ee-first": "1.1.1"
+ }
+ },
+ "parseurl": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz",
+ "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY="
+ },
+ "path-to-regexp": {
+ "version": "0.1.7",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
+ "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
+ },
+ "process-nextick-args": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
+ "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M="
+ },
+ "proxy-addr": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.5.tgz",
+ "integrity": "sha1-ccDuOxAt4/IC87ZPYI0XP8uhqRg=",
+ "requires": {
+ "forwarded": "0.1.0",
+ "ipaddr.js": "1.4.0"
+ }
+ },
+ "qs": {
+ "version": "6.4.0",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz",
+ "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM="
+ },
+ "range-parser": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
+ "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4="
+ },
+ "raw-body": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.2.0.tgz",
+ "integrity": "sha1-mUl2z2pQlqQRYoQEkvC9xdbn+5Y=",
+ "requires": {
+ "bytes": "2.4.0",
+ "iconv-lite": "0.4.15",
+ "unpipe": "1.0.0"
+ }
+ },
+ "readable-stream": {
+ "version": "2.2.7",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz",
+ "integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=",
+ "requires": {
+ "buffer-shims": "1.0.0",
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "1.0.0",
+ "process-nextick-args": "1.0.7",
+ "string_decoder": "1.0.3",
+ "util-deprecate": "1.0.2"
+ }
+ },
+ "regexp-clone": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz",
+ "integrity": "sha1-p8LgmJH9vzj7sQ03b7cwA+aKxYk="
+ },
+ "require_optional": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
+ "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==",
+ "requires": {
+ "resolve-from": "2.0.0",
+ "semver": "5.4.1"
+ }
+ },
+ "resolve-from": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz",
+ "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
+ },
+ "safe-buffer": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
+ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
+ },
+ "semver": {
+ "version": "5.4.1",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
+ "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg=="
+ },
+ "send": {
+ "version": "0.15.4",
+ "resolved": "https://registry.npmjs.org/send/-/send-0.15.4.tgz",
+ "integrity": "sha1-mF+qPihLAnPHkzZKNcZze9k5Bbk=",
+ "requires": {
+ "debug": "2.6.8",
+ "depd": "1.1.1",
+ "destroy": "1.0.4",
+ "encodeurl": "1.0.1",
+ "escape-html": "1.0.3",
+ "etag": "1.8.0",
+ "fresh": "0.5.0",
+ "http-errors": "1.6.2",
+ "mime": "1.3.4",
+ "ms": "2.0.0",
+ "on-finished": "2.3.0",
+ "range-parser": "1.2.0",
+ "statuses": "1.3.1"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.6.8",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
+ "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
+ "requires": {
+ "ms": "2.0.0"
+ }
+ }
+ }
+ },
+ "serve-static": {
+ "version": "1.12.4",
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.12.4.tgz",
+ "integrity": "sha1-m2qpjutyU8Tu3Ewfb9vKYJkBqWE=",
+ "requires": {
+ "encodeurl": "1.0.1",
+ "escape-html": "1.0.3",
+ "parseurl": "1.3.1",
+ "send": "0.15.4"
+ }
+ },
+ "setprototypeof": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz",
+ "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ="
+ },
+ "sliced": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
+ "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
+ },
+ "statuses": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz",
+ "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4="
+ },
+ "string_decoder": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
+ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
+ "requires": {
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "type-is": {
+ "version": "1.6.15",
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz",
+ "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=",
+ "requires": {
+ "media-typer": "0.3.0",
+ "mime-types": "2.1.16"
+ }
+ },
+ "unpipe": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
+ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+ },
+ "utils-merge": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz",
+ "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg="
+ },
+ "vary": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz",
+ "integrity": "sha1-Z1Neu2lMHVIldFeYRmUyP1h+jTc="
+ }
+ }
+}
diff --git a/public/.DS_Store b/public/.DS_Store
new file mode 100644
index 00000000..f674849e
Binary files /dev/null and b/public/.DS_Store differ
diff --git a/public/scripts/.DS_Store b/public/scripts/.DS_Store
new file mode 100644
index 00000000..5008ddfc
Binary files /dev/null and b/public/scripts/.DS_Store differ
diff --git a/public/scripts/app.js b/public/scripts/app.js
index 00988cd4..d583d1b2 100644
--- a/public/scripts/app.js
+++ b/public/scripts/app.js
@@ -2,6 +2,207 @@ console.log("Sanity Check: JS is working!");
$(document).ready(function(){
-// your code
+ // your code
+ //Create a variable to shorthand for the delete button section in the index.html
+ // $venueList = $("#bookTarget");
-});
+ //Step 1a, part 1 of 3:
+ //GET the api information and show it through renderMultipleVenues shown later on the page
+ $.ajax({
+ url: '/api/venues',
+ success: renderMultipleVenues,
+ });
+
+ //Step 1b, part 1 of 3:
+ $.ajax({
+ url: '/api/profile',
+ success: renderMyProfile,
+ });
+
+ // Step 2, 1 of 1: Create
+ // Update the index.html
+ $('#venue-form form').on('submit', function(event) {
+ event.preventDefault();
+ console.log("Prevents submit");
+ var formData = $(this).serialize();
+ console.log('formData', formData);
+ $.post('/api/venues', formData, function(venue) {
+ console.log('venue after POST', venue);
+ renderVenue(venue); //render the server's response
+ });
+ $(this).trigger("reset");
+ });
+
+
+
+ //Step 3a, 1 of 2: Edit
+ $('#venues').on('click', '.edit-venue', handleEditVenueClick);
+ //Step 3b, 1 of x: Save the Edits
+ $('#venues').on('click', '.save-venue', handleSaveChangesClick);
+ //Step 4, 1 of x: Delete
+ $('#venues').on('click', '.delete-venue', handleDeleteVenueClick);
+
+ //Step 3a, 2 of 2: Edit
+ function handleEditVenueClick(event) {
+ var $venueRow = $(this).closest('.venue');
+ var venueId = $venueRow.data("venue-id");
+ console.log('edit venue', venueId);
+ // show the save changes button
+ $venueRow.find('.save-venue').toggleClass('hidden');
+ // hide the edit button
+ $venueRow.find('.edit-venue').toggleClass('hidden');
+ var venueNotes =
+ $venueRow.find('span.venue-notes').text();
+ $venueRow.find('span.venue-notes').html('
');
+ };
+
+ //Step 3b, 2 of 3: Save the edits
+ //Saving changes from edits made
+ function handleSaveChangesClick(event) {
+ var venueId = $(this).parents('.venue').data('venue-id'); // $(this).closest would have worked fine too
+ var $venueRow = $('[data-venue-id=' + venueId + ']');
+ var data = {
+ notes: $venueRow.find('.edit-venue-notes').val()
+ };
+ console.log('PUTing data for venue', venueId, 'with data', data);
+ $.ajax({
+ method: 'PUT',
+ url: '/api/venues/' + venueId,
+ data: data,
+ success: handleVenueUpdatedResponse
+ });
+ }
+
+ //Step 3b, 3 of 3: Save the edits
+ function handleVenueUpdatedResponse(data) {
+ console.log('response to update', data);
+ var venueId = data._id;
+ // scratch this venue from the page
+ $('[data-venue-id=' + venueId + ']').remove();
+ renderVenue(data);
+ // $('[data-venue-id=' + venueId + ']')[0].scrollIntoView();
+ }
+
+ //Step 1a, 2 of 3:
+ //This runs through the forEach loop. Each item in the api will be shown and the renderVenue will display this per the function below
+ function renderMultipleVenues(venues) {
+ venues.forEach(function(venue) {
+ renderVenue(venue);
+ });
+ }
+ //Step 1b, 2 of 3:
+ function renderMyProfile(profiles) {
+ profiles.forEach(function(profile) {
+ renderProfile(profile);
+ });
+ }
+
+ // Step 4, 2 of x: Delete
+ // when a delete button for an venue is clicked
+ function handleDeleteVenueClick(event) {
+ var venueId = $(this).parents('.venue').data('venue-id');
+ console.log('someone wants to delete venue id=' + venueId );
+ $.ajax({
+ method: "delete",
+ url: "/api/venues/" + venueId,
+ }).then(function(data){
+ $(`[data-venue-id=${venueId}]`).remove();
+ });
+};
+
+ //Step 1a, part 3 of 3:
+ function renderVenue(venue) {
+ var venueHtml = (`
+
+
+
+
+
+
+
+

+
+
+
+ -
+
+ ${venue.name}
+
+ -
+
Location:
+ ${venue.location}
+
+ -
+
Website:
+ ${venue.website}
+
+ -
+
Notes:
+ ${venue.notes}
+
+
+
+
+
+
+
+
+
+
+ `);
+ $("#venues").prepend(venueHtml);
+ };
+
+ //Step 1b, part 3 of 3:
+ function renderProfile(profile) {
+ var profileHtml = (`
+
About the Author
+
+ `)
+ $("#profiles").prepend(profileHtml);
+ };
+
+
+
+
+ });
diff --git a/public/scripts/appOrig.js b/public/scripts/appOrig.js
new file mode 100644
index 00000000..86aa57fa
--- /dev/null
+++ b/public/scripts/appOrig.js
@@ -0,0 +1,218 @@
+console.log("Sanity Check: JS is working!");
+
+$(document).ready(function(){
+
+ // your code
+ //Create a variable to shorthand for the delete button section in the index.html
+ // $venueList = $("#bookTarget");
+
+ //Step 1a, part 1 of 3:
+ //GET the api information and show it through renderMultipleVenues shown later on the page
+ $.ajax({
+ url: '/api/venues',
+ success: renderMultipleVenues,
+ });
+
+ //Step 1b, part 1 of 3:
+ $.ajax({
+ url: '/api/profile',
+ success: renderMyProfile,
+ });
+
+ //Step 2, 1 of x: Create
+ //Update the index.html
+ $('#album-form form').on('submit', function(event) {
+ event.preventDefault();
+ var formData = $(this).serialize();
+ console.log('formData', formData);
+ $.post('/api/venues', formData, function(venue) {
+ console.log('venue after POST', venue);
+ renderVenue(venue); //render the server's response
+ });
+ $(this).trigger("reset");
+ });
+
+ //Step 3a, 1 of 2: Edit
+ $('#venues').on('click', '.edit-venue', handleEditVenueClick);
+ //Step 3b, 1 of x: Save the Edits
+ $('#venues').on('click', '.save-venue', handleSaveChangesClick);
+ //Step 4, 1 of x: Delete
+ $('#venues').on('click', '.delete-venue', handleDeleteVenueClick);
+
+ // $.when.apply(null, deferred).always(function() {
+ // console.log('all updates sent and received, time to refresh!');
+ // console.log(arguments);
+ // fetchAndReRenderVenueWithId(venueId);
+ // });
+ //
+ // function fetchAndReRenderVenueWithId(venueId) {
+ // $.get('/api/venues/' + venueId, function(data) {
+ // // remove the current instance of the venue from the page
+ // $('div[data-venue-id=' + venueId + ']').remove();
+ // // re-render it with the new venue data (including songs)
+ // renderVenue(data);
+ // });
+ // }
+
+ //Step 3a, 2 of 2: Edit
+ function handleEditVenueClick(event) {
+ var $venueRow = $(this).closest('.venue');
+ var venueId = $venueRow.data("venue-id");
+ console.log('edit venue', venueId);
+ // show the save changes button
+ $venueRow.find('.save-venue').toggleClass('hidden');
+ // hide the edit button
+ $venueRow.find('.edit-venue').toggleClass('hidden');
+ var venueNotes =
+ $venueRow.find('span.venue-notes').text();
+ $venueRow.find('span.venue-notes').html('
');
+ };
+
+ //Step 3b, 2 of x: Save the edits
+ //Saving changes from edits made
+ function handleSaveChangesClick(event) {
+ var venueId = $(this).parents('.venue').data('venue-id'); // $(this).closest would have worked fine too
+ var $venueRow = $('[data-venue-id=' + venueId + ']');
+ var data = {
+ venueNotes: $venueRow.find('.edit-venue-notes').val()
+ };
+ console.log('PUTing data for venue', venueId, 'with data', data);
+ $.ajax({
+ method: 'PUT',
+ url: '/api/venues/' + venueId,
+ data: data,
+ success: handleVenueUpdatedResponse
+ });
+ }
+
+ //Step 3b, 3 of x: Save the edits
+ function handleVenueUpdatedResponse(data) {
+ console.log('response to update', data);
+
+ var venueId = data._id;
+ // scratch this venue from the page
+ $('[data-venue-id=' + venueId + ']').remove();
+ renderVenue(data);
+
+ $('[data-venue-id=' + venueId + ']')[0].scrollIntoView();
+ }
+
+ //Step 1a, 2 of 3:
+ //This runs through the forEach loop. Each item in the api will be shown and the renderVenue will display this per the function below
+ function renderMultipleVenues(venues) {
+ venues.forEach(function(venue) {
+ renderVenue(venue);
+ });
+ }
+ //Step 1b, 2 of 3:
+ function renderMyProfile(profiles) {
+ profiles.forEach(function(profile) {
+ renderProfile(profile);
+ });
+ }
+
+ //Step 4, 2 of x: Delete
+ // when a delete button for an venue is clicked
+ function handleDeleteVenueClick(event) {
+ var venueId = $(this).parents('.venue').data('venue-id');
+ console.log('someone wants to delete venue id=' + venueId );
+ $.ajax({
+ url: '/api/venues/' + venueId,
+ method: 'DELETE',
+ success: handleDeleteVenueSuccess
+ });
+ }
+ //Step 4, 3 of x: Delete
+ // callback after DELETE /api/venue/:id
+ function handleDeleteVenueSuccess(data) {
+ var deletedVenueId = data._id;
+ console.log('removing the following venue from the page:', deletedVenueId);
+ $('div[data-venue-id=' + deletedVenueId + ']').remove();
+ }
+
+ //Step 1a, part 3 of 3:
+ function renderVenue(venue) {
+ var venueHtml = (`
+
+
+
+
+
+
+
+

+
+
+
+ -
+
+ ${venue.name}
+
+ -
+
Location:
+ ${venue.location}
+
+ -
+
Website:
+ ${venue.website}
+
+ -
+
Notes:
+ ${venue.notes}
+
+
+
+
+
+
+
+
+
+
+ `);
+ $("#venues").prepend(venueHtml);
+ };
+
+ //Step 1b, part 3 of 3:
+ function renderProfile(profile) {
+ var profileHtml = (`
+
About the Author
+
+ `)
+ $("#profiles").prepend(profileHtml);
+ };
+
+
+
+
+ });
diff --git a/public/styles/styles.css b/public/styles/styles.css
index 57b4da0e..5e1f20cd 100644
--- a/public/styles/styles.css
+++ b/public/styles/styles.css
@@ -1,10 +1,91 @@
body {
- color: #333;
- font-family: Helvetica, Arial, sans-serif;
- background-color: skyblue; /* Sanity Check! */
+ color: #fafafa;
+ font-family: "Open Sans Condensed";
+ font-size: 18px;
+ /*font-weight: 2px;*/
+ background-color: #181818;
+ background-repeat: no-repeat;
+ background-size: cover;
}
+
h1 {
margin-top: 100px;
text-align: center;
+
+ /*color: #181818;*/
+}
+
+h1:after
+{
+ content:' ';
+ display:block;
+ border:2px solid #181818;
+ margin-top: 10px;
+}
+h2 {
+ color: #75b0d4;
+}
+
+h3 {
+ color: #75b0d4;
+}
+
+/*BEG Jumbotron*/
+.jumbotron {
+ height: 400px;
+ background-repeat: no-repeat;
+ background-size: cover;
+ background-position: top;
+ text-align: center;
+ text-decoration-color: #181818;
+}
+/*END Jumbotron*/
+
+/*BEG Content*/
+.list-group-item {
+ padding: 5px 10px;
+ background-color: rgba(255, 255, 255, 0.5);
}
+.container {
+ padding-right: 10px;
+ padding-left: 10px;
+}
+.panel-footer {
+ background-color: rgba(255, 255, 255, 0.5);
+}
+/*End Content*/
+
+/*BEG Form */
+.venue-container {
+ background-repeat: no-repeat;
+ background-attachment: fixed;
+ background-position: center;
+ background-size: cover;
+ padding-top: 20px;
+}
+.venue-content {
+ padding-left: 15px;
+ padding-right: 15px;
+}
+/*End Form*/
+
+
+/*BEG Footer*/
+.bold {
+ font-size: 16px;
+ color: #75b0d4;
+}
+.standard {
+ font-size: 16px;
+}
+div.col-sm-2 {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+.footer-row {
+ display: flex;
+}
+
+/*END Footer*/
diff --git a/seed.js b/seed.js
index 896dead0..dc964b63 100644
--- a/seed.js
+++ b/seed.js
@@ -1,15 +1,80 @@
// This file allows us to seed our application with data
// simply run: `node seed.js` from the root of this project folder.
-// var db = require('./models');
+var db = require('./models');
-// var new_campsite = {description: "Sharp rocks. Middle of nowhere."}
+//Step 1, 1 of 2: This sets up your API
+ var venueList = [];
+ venueList.push({
+ name: "Oxford Social Club",
+ location: "San Diego",
+ website: "https://theoxfordsd.com/",
+ image: "https://pbs.twimg.com/profile_images/745999186265399296/AgQFU1QA.jpg",
+ notes: "Be Sophisticated or Don't",
+ imageBackground: "https://www.sandiego.com/sites/sandiego.com/files/styles/large/public/content/featured-content/sd-tour-1.jpg?itok=8KDQcQ5u",
+ });
+venueList.push({
+ name: "The Bungalow",
+ location: "Santa Monica",
+ website: "http://www.thebungalow.com/",
+ image: "https://s3-media1.fl.yelpcdn.com/bphoto/F-f7YjOFDd9b5jKVmkE84Q/ls.jpg",
+ notes: "Breezy, beachside Baja lifestyle",
+ imageBackground: "https://santamonicaflyers.com/wp-content/themes/atec/images/home-section02.jpg",
+ });
+venueList.push({
+ name: "The Battery",
+ location: "San Francisco",
+ website: "https://www.thebatterysf.com/club/",
+ image: "https://qph.ec.quoracdn.net/main-thumb-t-453945-200-wcuvopxyeusrfhqagrthqdwyvviwbgol.jpeg",
+ notes: "Diversity and intelligence with just a touch of the bizarre",
+ imageBackground: "https://www.homeadvisor.com/images/consumer/hhi/hero-photos/city/SanFrancisco.jpg",
+ });
+ // venueList.push({
+ // name: "Soho House",
+ // location: "West Hollywood",
+ // website: "https://www.sohohousewh.com/",
+ // image: "https://i.pinimg.com/736x/91/b5/d6/91b5d604798a1fee3b4cf0f433bbf45e--soho-house-west-hollywood.jpg",
+ // notes: "Assemble communities with creative souls",
+ // imageBackground: "http://wolfliketheanimal.com/wp-content/uploads/2013/06/12.jpg",
+ // });
-// db.Campsite.create(new_campsite, function(err, campsite){
-// if (err){
-// return console.log("Error:", err);
-// }
+ //Step 1, 2 of 2
+ //Next step, go to server.js file to set up requests
+ db.Venue.remove({}, function(err, venues){
+ db.Venue.create(venueList, function(err, venues){
+ if (err) { return console.log('ERROR', err); }
+ console.log("all venues:", venues);
+ console.log("created", venues.length, "venues");
+ process.exit();// we're all done! Exit the program.
+ });
+ });
-// console.log("Created new campsite", campsite._id)
-// process.exit(); // we're all done! Exit the program.
-// })
+ var profileList = [];
+ profileList.push({
+ name: "Carlynn Espinoza",
+ githubUsername: "Carlynn",
+ githubLink: "https://github.com/Carlynn",
+ githubProfileImage: "https://avatars1.githubusercontent.com/u/29782639?v=4&s=460",
+ personalSiteLink: "https://carlynn.github.io/",
+ currentCity: "San Francisco",
+ hobbies: [{
+ hobby: 'Travel',
+ destOne: 'Mexico City',
+ destTwo: 'Thailand',
+ destThree: "Africa",
+ }, {
+ hobby: 'Snowboarding',
+ destOne: 'Tahoe',
+ destTwo: 'Whistler',
+ destThree: 'Vail',
+ }]
+ });
+
+ db.Profile.remove({}, function(err, profiles){
+ db.Profile.create(profileList, function(err, profiles){
+ if (err) { return console.log('ERROR', err); }
+ console.log("complete profile:", profiles);
+ console.log("created", profiles.length, "profile");
+ process.exit();// we're all done! Exit the program.
+ });
+ });
diff --git a/server.js b/server.js
index fd366289..0f6bedb3 100644
--- a/server.js
+++ b/server.js
@@ -1,6 +1,7 @@
// require express and other modules
var express = require('express'),
- app = express();
+app = express();
+
// parse incoming urlencoded form data
// and populate the req.body object
@@ -16,22 +17,23 @@ app.use(function(req, res, next) {
});
/************
- * DATABASE *
- ************/
+* DATABASE *
+************/
-// var db = require('./models');
+var db = require('./models');
+var venues = db.Venue;
/**********
- * ROUTES *
- **********/
+* ROUTES *
+**********/
// Serve static files from the `/public` directory:
// i.e. `/images`, `/scripts`, `/styles`
app.use(express.static('public'));
/*
- * HTML Endpoints
- */
+* HTML Endpoints
+*/
app.get('/', function homepage(req, res) {
res.sendFile(__dirname + '/views/index.html');
@@ -39,29 +41,95 @@ app.get('/', function homepage(req, res) {
/*
- * JSON API Endpoints
- */
-
-app.get('/api', function apiIndex(req, res) {
- // TODO: Document all your api endpoints below as a simple hardcoded JSON object.
- // It would be seriously overkill to save any of this to your database.
- // But you should change almost every line of this response.
- res.json({
- woopsIForgotToDocumentAllMyEndpoints: true, // CHANGE ME ;)
- message: "Welcome to my personal api! Here's what you need to know!",
- documentationUrl: "https://github.com/example-username/express-personal-api/README.md", // CHANGE ME
- baseUrl: "http://YOUR-APP-NAME.herokuapp.com", // CHANGE ME
- endpoints: [
- {method: "GET", path: "/api", description: "Describes all available endpoints"},
- {method: "GET", path: "/api/profile", description: "Data about me"}, // CHANGE ME
- {method: "POST", path: "/api/campsites", description: "E.g. Create a new campsite"} // CHANGE ME
- ]
- })
+* JSON API Endpoints
+*/
+
+// Step 1a, 1 of 1
+//Show venues API data
+app.get('/api/venues', function (req, res) {
+ // send all venues as JSON response
+ db.Venue.find()
+ .exec(function(err, venues){
+ if (err) { return console.log("index error: " + err); }
+ res.json(venues);
+ });
+});
+
+// Step 1b, 1 of 1
+//Show profile API data
+app.get('/api/profile', function (req, res) {
+ db.Profile.find()
+ .exec(function(err, profiles){
+ if (err) { return console.log("index error: " + err); }
+ res.json(profiles);
+ });
});
+
+//Step 2, 1 of 2: Create
+app.post('/api/venues', function (req, res) {
+ // create new venue with form data (`req.body`)
+ var newVenue = new db.Venue({
+ name: req.body.name,
+ location: req.body.location,
+ website: req.body.website,
+ image: req.body.image,
+ notes: req.body.notes,
+ imageBackground: req.body.imageBackground,
+ });
+ db.Venue.create(req.body, function(err, venue) {
+ if (err) { console.log('error', err); }
+ console.log(venue);
+ res.json(venue);
+ });
+});
+
+//Step 2, 2 of 2: Updates the page
+app.get('/api/venues/:id', function (req, res) {
+ db.Venue.findByIdAndUpdate(req.params.id, req.params.body, function (err, venues) {
+ console.log('finding by ID');
+ res.json(venues);
+ });
+});
+
+//Step 3, 1 of 1: Update notes
+app.put('/api/venues/:id', function update(req,res){
+ // get venue id from url params (`req.params`)
+ console.log('venues notes updated', req.params);
+ var venueId = req.params.id;
+ // find venue in db by id
+ db.Venue.findOne({ _id: venueId }, function(err, foundVenue) {
+ if (err) {
+ res.status(500).json({ error: err.message });
+ } else {
+ // update the venues's attributes
+ foundVenue.notes = req.body.notes;
+ // save updated venue in db
+ foundVenue.save(function(err, savedVenue) {
+ if (err) {
+ res.status(500).json({ error: err.message });
+ } else {
+ res.json(savedVenue);
+ }
+ });
+ }
+ });
+});
+
+// Step 4, 1 of 1: Delete
+app.delete('/api/venues/:id', function (req, res) {
+ db.Venue.findByIdAndRemove(req.params.id, function(err, id_index){
+ console.log(id_index);
+ console.log("Done deleting");
+ res.status(200).send("Success!");
+ });
+});
+
+
+
/**********
- * SERVER *
- **********/
+* SERVER *
+**********/
// listen on the port that Heroku prescribes (process.env.PORT) OR port 3000
app.listen(process.env.PORT || 3000, function () {
diff --git a/views/index.html b/views/index.html
index 48e39ae6..6ec7d82e 100644
--- a/views/index.html
+++ b/views/index.html
@@ -1,29 +1,104 @@
-
-
-
+
+
+
-
Blank
+
Bad and Boujee
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
Welcome to Bad and Boujee Venues
+
Come explore an explicit list of swanky botique settings within California.
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+