-
Notifications
You must be signed in to change notification settings - Fork 54
I want to review your code #34
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
base: master
Are you sure you want to change the base?
Changes from 11 commits
236c1bc
c00ba9c
4a08f9e
45acb74
c993772
c757ed2
7e35d2b
5ff575f
435738c
d91bfb2
e38a2d7
d638151
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| **/node_modules | ||
|
|
||
| node_modules |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| function index(req, res) { | ||
| res.json({ | ||
| message: "Welcome to my personal API!", | ||
| documentation_url: "https://github.com/jcheng305/express-personal-api", | ||
| base_url: "localhost:3000", | ||
| endpoints: [ | ||
| { | ||
| method: "GET", path: "/api", description: "Describes available endpoints" | ||
| } | ||
| ] | ||
| }); | ||
| } | ||
|
|
||
| module.exports = { | ||
| index: index | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| module.exports = { | ||
| api: require('./apiController'), | ||
| lists: require('./motorcycleListController') | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /*********** | ||
| * DATABASE * | ||
| ************/ | ||
|
|
||
| /* hard-coded data */ | ||
| var motorcycleLists = []; | ||
|
|
||
| motorcycleLists.push({ | ||
| _id: 132, | ||
| make: 'BMW', | ||
| model: 'S1000RR', | ||
| image: '/images/s1000rr.jpg', | ||
| releaseDate: '2009 to current', | ||
| weight: '403 lbs', | ||
| maxPower: '199 hp at 13,500 rpm', | ||
| maxTorque: '83 lb.-ft. at 10,500 rpm', | ||
| engineDisplacement: '999 cc' | ||
| }); | ||
| motorcycleLists.push({ | ||
| _id: 133, | ||
| make: 'Honda', | ||
| model: 'CBR1000RR', | ||
| image: '/images/cbr1000rr.jpg', | ||
| releaseDate: '2008 to current', | ||
| weight: '439 lbs', | ||
| maxPower: '153.4 hp at 10,700 rpm', | ||
| maxTorque: '78.74 lb.-ft. at 9,400 rpm', | ||
| engineDisplacement: '999 cc' | ||
| }); | ||
| motorcycleLists.push({ | ||
| _id: 134, | ||
| make: 'Triumph', | ||
| model: 'Daytona 675R', | ||
| image: '/images/675r.jpg', | ||
| releaseDate: '2006 to current', | ||
| weight: '363 lbs', | ||
| maxPower: '104 hp at 13,500 rpm', | ||
| maxTorque: '53 lb.-ft. at 10,500 rpm', | ||
| engineDisplacement: '674 cc' | ||
| }) | ||
| motorcycleLists.push({ | ||
| _id: 135, | ||
| make: 'Suzuki', | ||
| model: 'GSX-R 750', | ||
| image: '/images/gsxr750.jpg', | ||
| releaseDate: '2011 to current', | ||
| weight: '418 lbs', | ||
| maxPower: '148 hp at 12,800 rpm', | ||
| maxTorque: '64 lb.-ft. at 11,200 rpm', | ||
| engineDisplacement: '749 cc' | ||
| }); | ||
|
|
||
| // GET /api/albums | ||
| function index(req, res) { | ||
| // send back all albums as JSON | ||
| } | ||
|
Author
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. Add something like this to grab data from your database, probably need to add data into the database first or seed it? db.Profile.find({}, function(err, dataReturned) { 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. 👍 |
||
|
|
||
| // POST /api/albums | ||
| function create(req, res) { | ||
| // create an album based on request body and send it back as JSON | ||
| } | ||
|
|
||
| // GET /api/albums/:albumId | ||
| function show(req, res) { | ||
| // find one album by id and send it back as JSON | ||
| } | ||
|
|
||
| // DELETE /api/albums/:albumId | ||
| function destroy(req, res) { | ||
| // find one album by id, delete it, and send it back as JSON | ||
| } | ||
|
|
||
| // PUT or PATCH /api/albums/:albumId | ||
| function update(req, res) { | ||
| // find one album by id, update it based on request body, | ||
| // and send it back as JSON | ||
| } | ||
|
|
||
|
|
||
| // export public methods here | ||
| module.exports = { | ||
| index: index, | ||
| create: create, | ||
| show: show, | ||
| destroy: destroy, | ||
| update: update | ||
| }; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // var mongoose = require('mongoose'), | ||
| // const Schema = mongoose.Schema; | ||
|
|
||
| // var CampsiteSchema = new Schema({ | ||
| // description: String | ||
| // }); | ||
|
|
||
| // var Campsite = mongoose.model('Campsite', CampsiteSchema); | ||
|
|
||
| // module.exports = Campsite; | ||
|
|
||
| var mongoose = require('mongoose'), | ||
| Schema = mongoose.Schema; | ||
|
|
||
| const ProfileSchema = new Schema ({ | ||
|
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. It seems like this is data about a motorcycle; why is it in a file called Profile? |
||
| make: String, | ||
| model: String, | ||
| image: String, | ||
| releaseDate: String, | ||
| weight: String, | ||
| maxPower: String, | ||
| maxTorque: String, | ||
| engineDisplacement: String | ||
| }); | ||
|
|
||
| const Profile = mongoose.model('Profile', ProfileSchema); | ||
|
|
||
| module.exports = Profile; | ||
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.
Add something like this to grab all your models/database tables:
var db = require('../models');