diff --git a/controllers/apiController.js b/controllers/apiController.js new file mode 100644 index 00000000..7395845c --- /dev/null +++ b/controllers/apiController.js @@ -0,0 +1,16 @@ +function index(req, res) { + res.json({ + message: "Welcome to Skatespot.com!", + // documentation_url: "https://github.com/sf-wdi-labs/tunely", + // base_url: "localhost:3000", + endpoints: [ + { + method: "GET", path: "/api", description: "Describes available endpoints" + } + ] + }); +} + +module.exports = { + index: index +} diff --git a/controllers/index.js b/controllers/index.js new file mode 100644 index 00000000..2e5bae7f --- /dev/null +++ b/controllers/index.js @@ -0,0 +1,4 @@ +module.exports = { + api: require('./apiController'), + albums: require('./skatespotController'), +} diff --git a/controllers/skatespotController.js b/controllers/skatespotController.js new file mode 100644 index 00000000..49fc0871 --- /dev/null +++ b/controllers/skatespotController.js @@ -0,0 +1,55 @@ +/************ + * DATABASE * + ************/ + +var db = require('../models'); + +// // GET /api/skatespots +// function index(req, res) { +// db.Skatespot.find({}, function(err, allSpots){ +// res.json(allSpots); +// }); +// } +// +// // POST /api/skatespots +// function create(req, res) { +// console.log('body', req.body); +// var attributes = req.body.attributes.split(',').map(function(item){ +// return item.trim();}) +// req.body.attributes = attributes; +// db.Skatespot.create(req.body, function(err,skatespot){ +// if(err) {console.log('error',err);} +// console.log(skatespot); +// res.json(skatespot); +// }) +// } +// +// // GET /api/skatespots/:skatespotId +// function show(req, res) { +// db.Skatespot.findById(req.params.skatespotId, function(err, foundSkatespot) { +// if(err) { console.log('skatespotController.show error', err); } +// console.log('skatespotController.show responding with', foundSkatespot); +// res.json(foundSkatespot); +// }); +// } + +// DELETE /api/skatespots/:skatespotsId +function destroy(req, res) { + + +} + +// PUT or PATCH /api/skatespots/:skatespotsId +function update(req, res) { + +} + + +// export public methods here +module.exports = { + index: index, + create: create, + show: show, + destroy: destroy, + update: update +}; 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..c2743caf 100644 --- a/models/index.js +++ b/models/index.js @@ -2,4 +2,4 @@ var mongoose = require("mongoose"); mongoose.connect( process.env.MONGODB_URI || "mongodb://localhost/personal-api", {useMongoClient: true}); mongoose.Promise = global.Promise; // use native Promise -// module.exports.Campsite = require("./campsite.js.example"); +module.exports.Skatespot = require("./skatespot.js"); diff --git a/models/skatepark.js b/models/skatepark.js new file mode 100644 index 00000000..af4caa63 --- /dev/null +++ b/models/skatepark.js @@ -0,0 +1,14 @@ +var mongoose = require('mongoose'), + Schema = mongoose.Schema; + +var SkatespotSchema = new Schema({ + spotName: String, + address: String, + generalDirections: String, + attributes: [String], + // img: +}); + +var Skatespot = mongoose.model('Skatespot', SkatespotSchema); + +module.exports = Skatespot; diff --git a/package.json b/package.json index 22718d9e..8ad80d95 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,11 @@ "homepage": "https://github.com/SF-WDI-LABS/express-personal-api", "dependencies": { "body-parser": "^1.15.0", + "bower": "^1.8.0", "express": "^4.13.4", - "mongoose": "^4.4.10" + "express-session": "^1.15.5", + "method-override": "^2.3.9", + "mongoose": "^4.4.10", + "nodemon": "^1.11.0" } } diff --git a/public/styles/styles.css b/public/styles/styles.css index 57b4da0e..ee55207e 100644 --- a/public/styles/styles.css +++ b/public/styles/styles.css @@ -1,10 +1,26 @@ -body { - color: #333; - font-family: Helvetica, Arial, sans-serif; - background-color: skyblue; /* Sanity Check! */ +.jumbotron { + background-image: url(http://www.revolution.co.za/wp-content/uploads/2015/02/Screen-shot-2015-02-13-at-10.41.00-AM.jpg); + background-size: cover; + background-repeat: no-repeat; + color: #EEE; +} +.jumbotron .container { + height: 450px; } -h1 { - margin-top: 100px; +.inline-header { + display: center; + vertical-align: baseline; + margin-right: 12px; +} +legend { + text: bold; +} +.footer{ + background-color: black; + margin-top: 20px; + padding-top: 20px; + min-height: 200px; text-align: center; + color: white; } diff --git a/seed.js b/seed.js index 896dead0..136fb433 100644 --- a/seed.js +++ b/seed.js @@ -1,15 +1,15 @@ // 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."} +var new_skatepark = {description: "Sharp rocks. Middle of nowhere."} -// db.Campsite.create(new_campsite, function(err, campsite){ -// if (err){ -// return console.log("Error:", err); -// } +db.Skatepark.create(new_skatepark, function(err, skatepark){ + if (err){ + return console.log("Error:", err); + } -// console.log("Created new campsite", campsite._id) -// process.exit(); // we're all done! Exit the program. -// }) + console.log("Created new skatepark", skatepark._id) + process.exit(); // we're all done! Exit the program. +}) diff --git a/server.js b/server.js index fd366289..c7bde135 100644 --- a/server.js +++ b/server.js @@ -19,7 +19,7 @@ app.use(function(req, res, next) { * DATABASE * ************/ -// var db = require('./models'); +var db = require('./models'); /********** * ROUTES * @@ -49,12 +49,12 @@ app.get('/api', function apiIndex(req, res) { 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 + documentationUrl: "https://github.com/deathofasellout/express-personal-api/README.md", // CHANGE ME + baseUrl: "https://immense-cove-18493.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 + {method: "POST", path: "/api/skateparks", description: "E.g. Create a new skatepark"} // CHANGE ME ] }) }); diff --git a/views/index.html b/views/index.html index 48e39ae6..632c2654 100644 --- a/views/index.html +++ b/views/index.html @@ -12,18 +12,76 @@ +
-Find a Skatespot!