forked from sf-wdi-25/express_self_api
-
Notifications
You must be signed in to change notification settings - Fork 54
Carlynn's Personal API #28
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
Open
Carlynn
wants to merge
10
commits into
SF-WDI-LABS:master
Choose a base branch
from
Carlynn:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e7c58da
ready for heroku deploy attempt #1
Carlynn 8a36ade
API posts to page
Carlynn 3c91bd5
Edit Notes button works
Carlynn f149a75
Test Save
Carlynn 2feccbc
weeerrrkkk
Carlynn 1ca128f
Delete function works
Carlynn 7f51a85
Edit notes updated, result undefined
Carlynn 32c04ac
CRUD and CSS
Carlynn 5c95c88
test
Carlynn fd34a6d
Working
Carlynn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| 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.Venue = require("./venue.js"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| var mongoose = require('mongoose'), | ||
| Schema = mongoose.Schema; | ||
|
|
||
| var VenueSchema = new Schema({ | ||
| name: String, | ||
| location: String, | ||
| website: String, | ||
| image: String, | ||
| notes: String, | ||
| }); | ||
|
|
||
| var Venue = mongoose.model('Venue', VenueSchema); | ||
|
|
||
| module.exports = Venue; |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| 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"); | ||
| //This will pull the api information from the below path | ||
| $.ajax({ | ||
| url: '/api', | ||
| success: handleSuccess, | ||
| error: handleError | ||
| }); | ||
|
|
||
| //Create a new form on the submit button | ||
| //Create a submit button in the index.html | ||
| $('#newVenueForm').on('submit', function(event) { | ||
| //Prevent the button from submitting AKA refreshing the page | ||
| event.preventDefault(); | ||
| //POST the new information to the path below and will turn it into a string using serialize | ||
| $.ajax({ | ||
| method: 'POST', | ||
| url: '/api', | ||
| data: $(this).serialize(), | ||
| success: newVenueSuccess, | ||
| error: newVenueError | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
|
|
||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| body { | ||
| color: #fafafa; | ||
| font-family: Helvetica, Arial, sans-serif; | ||
| background-color: #181818; | ||
| background-repeat: no-repeat; | ||
| background-size: cover; | ||
| } | ||
|
|
||
| h1 { | ||
| margin-top: 100px; | ||
| text-align: center; | ||
| color: white; | ||
| } | ||
| h2 { | ||
| color: #75b0d4; | ||
| } | ||
|
|
||
| h3 { | ||
| color: #75b0d4; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +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 new_campsite = {description: "Sharp rocks. Middle of nowhere."} | ||
|
|
||
| // db.Campsite.create(new_campsite, function(err, campsite){ | ||
| // if (err){ | ||
| // return console.log("Error:", err); | ||
| // } | ||
|
|
||
| // console.log("Created new campsite", campsite._id) | ||
| // process.exit(); // we're all done! Exit the program. | ||
| // }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| // require express and other modules | ||
| var express = require('express'), | ||
| app = express(); | ||
|
|
||
|
|
||
| // parse incoming urlencoded form data | ||
| // and populate the req.body object | ||
| var bodyParser = require('body-parser'); | ||
| app.use(bodyParser.urlencoded({ extended: true })); | ||
|
|
||
| // allow cross origin requests (optional) | ||
| // https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS | ||
| app.use(function(req, res, next) { | ||
| res.header("Access-Control-Allow-Origin", "*"); | ||
| res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); | ||
| next(); | ||
| }); | ||
|
|
||
| /************ | ||
| * DATABASE * | ||
| ************/ | ||
|
|
||
| var db = require('./models'); | ||
|
|
||
| /********** | ||
| * ROUTES * | ||
| **********/ | ||
|
|
||
| // Serve static files from the `/public` directory: | ||
| // i.e. `/images`, `/scripts`, `/styles` | ||
| app.use(express.static('public')); | ||
|
|
||
| /* | ||
| * HTML Endpoints | ||
| */ | ||
|
|
||
| app.get('/', function homepage(req, res) { | ||
| res.sendFile(__dirname + '/views/index.html'); | ||
| }); | ||
|
|
||
|
|
||
| /* | ||
| * JSON API Endpoints | ||
| */ | ||
| app.get('/api/profile', function apiIndex(req,res) { | ||
| res.json({ | ||
| endpoints: [{ | ||
| 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: [ | ||
| { | ||
| optionOne: "Answer A", | ||
| optionTwo: "Answer B", | ||
| }, | ||
| { | ||
| optionThree: "Answer C", | ||
| optionFour: "Answer D", | ||
| }, | ||
| ] | ||
| }] | ||
| }); | ||
| }); | ||
|
|
||
| app.get('/api', function apiIndex(req, res) { | ||
| res.json({ | ||
| endpoints: [ | ||
| { | ||
| 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", | ||
| }, | ||
| { | ||
| 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", | ||
| }, | ||
| { | ||
| 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", | ||
| }, | ||
| ] | ||
| }) | ||
| }); | ||
|
|
||
|
|
||
| router.get("/", require("./controllers/index")); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So much commented out code!! We let it slide the first couple projects but we're going to get nit-pickier about these things moving forward. You should make sure that you're not leaving in console.logs or commented out code. |
||
| // router.post("/", require("./controllers/create")); | ||
| // router.put("/:id", require("./controllers/update")); | ||
| // router.get("/:id/edit", require("./controllers/edit")); | ||
| // app.delete("/:id", require("./controllers/destroy")); | ||
|
|
||
| // 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: "pizza"}, // CHANGE ME | ||
| // {method: "POST", path: "/api/campsites", description: "E.g. Create a new campsite"} // CHANGE ME | ||
| // ] | ||
| // }) | ||
| // }); | ||
|
|
||
| /********** | ||
| * SERVER * | ||
| **********/ | ||
|
|
||
| // listen on the port that Heroku prescribes (process.env.PORT) OR port 3000 | ||
| app.listen(process.env.PORT || 3000, function () { | ||
| console.log('Express server is up and running on http://localhost:3000/'); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
|
||
| <title>Bad and Boujee</title> | ||
|
|
||
| <!-- STYLESHEETS --> | ||
| <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> | ||
| <link rel="stylesheet" href="/styles/styles.css"> | ||
|
|
||
| <!-- VENDOR SCRIPTS --> | ||
| <script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> | ||
|
|
||
| <!-- APPLICATION SCRIPTS --> | ||
| <script src="/scripts/app.js"></script> | ||
| </head> | ||
| <body> | ||
| <div class="container-fluid"> | ||
| <div class="row"> | ||
| <div class="col-sm-10 col-sm-offset-1" style="border: orange solid 2px"> | ||
| <h1>BAD and BOUJEE</h1> | ||
| <h3>Venues</h3> | ||
| <h2>Venues</h2> | ||
|
|
||
| <!--One Venue--> | ||
| <!-- Wrap the entire html for one venue within a form. This will be called back in the app.js --> | ||
| <form class="form-inline" id="newVenueForm"> | ||
| <div class="row margin-top-20 wine-container" style="border: blue solid 2px"> | ||
| <div class="col-sm-3"> | ||
| <img src="http://www.modern-traveler.com/wp-content/uploads/2017/02/Oxford-Social-Club.jpg" class="img-responsive" /> | ||
| </div> | ||
| <div class="col-sm-9" style="border: pink solid 2px"> | ||
| <div class="margin-top-20"> | ||
| <span><b>Name: </b></span><span>TestName</span> | ||
| </div> | ||
| <div> | ||
| <span><b>Location: </b></span><span>TestLocation</span> | ||
| </div> | ||
| <div> | ||
| <span><b>Website: </b></span><span>TestWebsite</span> | ||
| </div> | ||
| <div> | ||
| <span><b>Image: </b></span><span>TestImage</span> | ||
| </div> | ||
| <div> | ||
| <span><b>Notes: </b></span><span>TestNotes</span> | ||
| </div> | ||
| <div class="margin-top-10"> | ||
| </div> | ||
| <div class="margin-top-20"> | ||
| <a class="btn btn-default">Edit Notes</a> | ||
| </div> | ||
| </form> | ||
| <!-- app.js will target this to create a delete button --> | ||
| <div id="bookTarget"></div> | ||
| </div> | ||
| </div> | ||
| <!--/One Wine--> | ||
| <div class="footer"> | ||
| <h3>About the Author</h3> | ||
| <div class="col-sm-2"> | ||
| <img src="https://avatars1.githubusercontent.com/u/29782639?v=4&s=460" class="img-responsive" style="width: 100px"/> | ||
| </div> | ||
| <div class="col-sm-10" style="border: pink solid 2px"> | ||
| <div class="margin-top-20"> | ||
| <div> | ||
| <span><b>Name: </b></span><span>myName</span> | ||
| </div> | ||
| <div> | ||
| <span><b>Github Link: </b></span><span>TestLocation</span> | ||
| </div> | ||
| <div> | ||
| <span><b>Personal Site Link: </b></span><span>TestLocation</span> | ||
| </div> | ||
| <div> | ||
| <span><b>Current City: </b></span><span>TestLocation</span> | ||
| </div> | ||
| <div> | ||
| <span><b>Hobbies: </b></span><span>TestLocation</span> | ||
| </div> | ||
| <div> | ||
| <span><b>Location: </b></span><span>TestLocation</span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You set up the variable "db" but you never use it...