Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
a11a00f
created routes files, pseudocode and lib file
jweeber Jun 14, 2016
991bd14
pseudocoded all the routes. ALL OF THEM
jweeber Jun 14, 2016
9e4894d
semicolon destructiongit add .
jweeber Jun 14, 2016
36c5ab2
completed /zomg route, json is successful
jweeber Jun 14, 2016
da05488
Added an images folder and inside put our ERD
dri19tcc Jun 14, 2016
f8ba0ae
Added massive dependencies, added extra scripts for our database
dri19tcc Jun 14, 2016
2c42d48
added load_schema with all database tables and what they will need. …
dri19tcc Jun 14, 2016
32edfb7
route for customers index created
jweeber Jun 15, 2016
cf26e91
movies index route created
jweeber Jun 15, 2016
9fc335b
added rentals/:title route
jweeber Jun 15, 2016
b9741f8
Added seeding data into database, changed schema for rentals to text,…
dri19tcc Jun 15, 2016
769fbe8
Trying to get data to customers page
dri19tcc Jun 16, 2016
01145b5
Added in controllers and customers to get json data as the output
dri19tcc Jun 16, 2016
8d3924c
getting all customers working
jweeber Jun 16, 2016
d44c8ac
moved customer.all function to model and rendered json data from cont…
jweeber Jun 16, 2016
5821a8d
added first fucking test for customers controller and it is PASSING
jweeber Jun 16, 2016
e238cae
added two more passing tests weeee
jweeber Jun 16, 2016
b194f8b
Added a show page for just one customer
dri19tcc Jun 16, 2016
a53ef69
Added in a sort by function that can sort by different fields, and ad…
dri19tcc Jun 16, 2016
aa21741
cleaned up code
dri19tcc Jun 16, 2016
a8d7a0a
get /movies working to retrieve all movies. routes created for /:id a…
jweeber Jun 17, 2016
84501a7
model and controller methods for find and sort working for movies.
jweeber Jun 17, 2016
05f7e0a
three tests for movies done and passing
jweeber Jun 17, 2016
dcd0b51
test for finding a movie based on title written and passing
jweeber Jun 17, 2016
db04330
minor movies test revision to use var for title and remove magic string
jweeber Jun 17, 2016
1a848f6
Added in more tests for customers. Added a negative test for giving …
dri19tcc Jun 17, 2016
2205615
Added in negative tests for movies and for customers
dri19tcc Jun 17, 2016
e7f12f1
Took out lower level error
dri19tcc Jun 17, 2016
78b0ef5
added movie_id to schema
jweeber Jun 17, 2016
529da05
find all movies that can be rented works. find rentals by title now w…
jweeber Jun 17, 2016
47c9e4f
changed schema
dri19tcc Jun 17, 2016
63a2dc8
Added in controller testing
dri19tcc Jun 17, 2016
65ad737
Added in controller testing for rentals for show page
dri19tcc Jun 17, 2016
5bdd0d2
Added customer testing for show page
dri19tcc Jun 17, 2016
ff1ca1a
Cleaned up customers controller page
dri19tcc Jun 17, 2016
5d34cc3
Added jasmine-testing so errors will show
dri19tcc Jun 18, 2016
05e2ced
Added rental tests
dri19tcc Jun 18, 2016
b04c9e9
Have all passing tests for all controllers and functions and all mode…
dri19tcc Jun 18, 2016
440cae3
added temporary seed data to test customer routes for current checked…
jweeber Jun 20, 2016
955c5d9
findRentals method in model retrieving rentals data from temp seeded …
jweeber Jun 20, 2016
42f00a0
rental history for customers working with temp seed data
jweeber Jun 20, 2016
2dee49d
created sql file for inner joining rentals, movies, customers. return…
jweeber Jun 20, 2016
cc8267f
trying to get current movies out
dri19tcc Jun 20, 2016
ef51688
Debugging movies rental history
dri19tcc Jun 20, 2016
fdeb7ce
one customer showing up for current rentals.
jweeber Jun 20, 2016
3d331b7
finally got list of customers who currently have specific movie check…
jweeber Jun 20, 2016
eb7550b
Added a checkout date column for rentals
dri19tcc Jun 20, 2016
6d405c5
Cleaned up code
dri19tcc Jun 21, 2016
e1880ae
Added controller testing and adding coverage to git ignore
dri19tcc Jun 21, 2016
fd5b67c
Added model testing
dri19tcc Jun 21, 2016
51fbee5
writing tests for rentals, working on negative tests
jweeber Jun 21, 2016
d474782
Added negative tests
dri19tcc Jun 21, 2016
675cbb0
Cleaned up rental spec code, if using find, no callback error is given
dri19tcc Jun 21, 2016
0a0a408
working on get currently checked out movies customers
jweeber Jun 21, 2016
54b8a52
merging rentals model with removing error handling
jweeber Jun 21, 2016
64f37a0
Took out error handling because no errors passed when using the .find…
dri19tcc Jun 21, 2016
4d4b7e7
finished tests for rentals model so far
jweeber Jun 21, 2016
99b79af
Merge branch 'master' of github.com:jweeber/VideoStoreAPI
dri19tcc Jun 21, 2016
4651ad4
finished tests for customer model
jweeber Jun 21, 2016
9e37fb4
Added more seeding data, added movies route
dri19tcc Jun 21, 2016
3724763
Added a new sql file to query customer rental history, added a new ro…
dri19tcc Jun 21, 2016
2911550
Added an index controller so route testing would be at 100%
dri19tcc Jun 22, 2016
3a665c2
Added current rentals and started on post
dri19tcc Jun 22, 2016
ffa61bc
Adding post route
dri19tcc Jun 22, 2016
2e9d342
Working on checkout posting data
dri19tcc Jun 22, 2016
5d5624f
post to checkout working. we fancy! saving to rentals database as che…
jweeber Jun 22, 2016
7c59385
Rental method for chekcout now successfully reducing inventory
jweeber Jun 22, 2016
5584486
return date calculates and saves to rental database
jweeber Jun 22, 2016
52fcae5
extracting logic from rental checkout method for reusability. added l…
jweeber Jun 23, 2016
3a5c9f3
added router for rental checkin, plus controller method and model met…
jweeber Jun 23, 2016
f035554
got error handling working for when inventory is less than 1
jweeber Jun 23, 2016
2678ec4
Added a find by id method
dri19tcc Jun 23, 2016
a189ac7
Added function to charge a customer 1.00 to rent out. Went into the …
dri19tcc Jun 23, 2016
2fc868d
Made put routes, and renamed functions as put
dri19tcc Jun 23, 2016
935a54c
Changed rental database to false and added to movie inventory when re…
dri19tcc Jun 23, 2016
d5d4db6
Added ; in sql query, renamed so functions matched
dri19tcc Jun 23, 2016
075bed0
made routes and started method for overdue
dri19tcc Jun 24, 2016
f6698f6
overdue rentals model working to return rentals, working on getting i…
jweeber Jun 24, 2016
2e0369e
Found a missing token
dri19tcc Jun 24, 2016
c166224
Added a sql file to join customers and rentals
dri19tcc Jun 24, 2016
2366743
Sql file is working, yay
dri19tcc Jun 24, 2016
e6a0e2e
Finished function to return customers that have late data
dri19tcc Jun 24, 2016
a330a7a
updating
dri19tcc Jun 24, 2016
9cd7d07
merging
jweeber Jun 24, 2016
adab1a0
merge conflict
jweeber Jun 24, 2016
2e97025
fixed customer rental history to order by checkout and show movies
jweeber Jun 24, 2016
50740f6
fixed current rentals by customer to show movies
jweeber Jun 24, 2016
417de7e
fixing sql for movie rental history showing customers
jweeber Jun 24, 2016
4092545
fixed overdue rentals to show info for customer and movies
jweeber Jun 24, 2016
6e8adf2
fixed tests after changing methods in rental model to use sql
jweeber Jun 24, 2016
bb39da2
don't know
dri19tcc Jun 24, 2016
5b51525
merge conflicts
dri19tcc Jun 24, 2016
04e0654
Added a new directory that will hold api json doc, started writing up…
dri19tcc Jun 24, 2016
90e9a3f
tried more tests for rentals. some are just not working out.
jweeber Jun 25, 2016
dcfe8e5
merging tests
jweeber Jun 25, 2016
79d1d86
got another test working so up to 90% coverage for models
jweeber Jun 25, 2016
a8a4603
cleaning up test file
jweeber Jun 25, 2016
32e4fb0
json docs
dri19tcc Jun 26, 2016
182a16b
merging
dri19tcc Jun 26, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
node_modules/
/coverage
135 changes: 135 additions & 0 deletions api/docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"links": {
"customers": "http://localhost:3000/customers",
"customer_show": "http://localhost/customers/:name",
"customer_sort": "http://localhost/customers/sort/:field?n=[limit]p=[offset]",
"customer_current": "http://localhost/customers/:id/current",
"customer_history": "http://localhost/customers/:id/history"
},
"data": [{
"type": "customers",
"id": "1",
"attributes": {
"name": "Shelley Rocha",
"registered_at": "Wed, 29 Apr 2015 07:54:14 -0700",
"address": "Ap #292-5216 Ipsum Rd.",
"city": "Hillsboro",
"state": "OR",
"postal_code": "24309",
"phone": "(322) 510-8695",
"account_credit": "13.15"
},
"type": "customers_show",
"id": "1",
"attributes": {
"name": "Shelley Rocha",
"registered_at": "Wed, 29 Apr 2015 07:54:14 -0700",
"address": "Ap #292-5216 Ipsum Rd.",
"city": "Hillsboro",
"state": "OR",
"postal_code": "24309",
"phone": "(322) 510-8695",
"account_credit": "13.15"
},
"type": "customers_sort",
"field": "name",
"n": "number",
"p": "offset",
"attributes": {
"name": "Shelley Rocha",
"registered_at": "Wed, 29 Apr 2015 07:54:14 -0700",
"address": "Ap #292-5216 Ipsum Rd.",
"city": "Hillsboro",
"state": "OR",
"postal_code": "24309",
"phone": "(322) 510-8695",
"account_credit": "13.15"
},
"type": "customers_current",
"id": "1",
"attributes": {
"id": 29,
"title": "The Shining",
"overview": "Jack Torrance accepts a caretaker job at the Overlook Hotel, where he, along with his wife Wendy and their son Danny, must live isolated from the rest of the world for the winter. But they aren't prepared for the madness that lurks within.",
"release_date": "1980-05-22",
"inventory": 3
},
"type": "customers_history",
"id": "1",
"attributes": {
"id": 29,
"title": "The Shining",
"overview": "Jack Torrance accepts a caretaker job at the Overlook Hotel, where he, along with his wife Wendy and their son Danny, must live isolated from the rest of the world for the winter. But they aren't prepared for the madness that lurks within.",
"release_date": "1980-05-22",
"inventory": 3
}
}]
}

{
"links": {
"customers": "http://localhost:3000/movies",
"customer_show": "http://localhost/movies/sort/:field?n=[limit]p=offset",
"customer_sort": "http://localhost/movies/:title/current",
"customer_current": "http://localhost/movies/:title/history",
"customer_history": "http://localhost/movies/:id/history"
},
"data": [{
"type": "customers",
"id": "1",
"attributes": {
"name": "Shelley Rocha",
"registered_at": "Wed, 29 Apr 2015 07:54:14 -0700",
"address": "Ap #292-5216 Ipsum Rd.",
"city": "Hillsboro",
"state": "OR",
"postal_code": "24309",
"phone": "(322) 510-8695",
"account_credit": "13.15"
},
"type": "customers_show",
"id": "1",
"attributes": {
"name": "Shelley Rocha",
"registered_at": "Wed, 29 Apr 2015 07:54:14 -0700",
"address": "Ap #292-5216 Ipsum Rd.",
"city": "Hillsboro",
"state": "OR",
"postal_code": "24309",
"phone": "(322) 510-8695",
"account_credit": "13.15"
},
"type": "customers_sort",
"field": "name",
"n": "number",
"p": "offset",
"attributes": {
"name": "Shelley Rocha",
"registered_at": "Wed, 29 Apr 2015 07:54:14 -0700",
"address": "Ap #292-5216 Ipsum Rd.",
"city": "Hillsboro",
"state": "OR",
"postal_code": "24309",
"phone": "(322) 510-8695",
"account_credit": "13.15"
},
"type": "customers_current",
"id": "1",
"attributes": {
"id": 29,
"title": "The Shining",
"overview": "Jack Torrance accepts a caretaker job at the Overlook Hotel, where he, along with his wife Wendy and their son Danny, must live isolated from the rest of the world for the winter. But they aren't prepared for the madness that lurks within.",
"release_date": "1980-05-22",
"inventory": 3
},
"type": "customers_history",
"id": "1",
"attributes": {
"id": 29,
"title": "The Shining",
"overview": "Jack Torrance accepts a caretaker job at the Overlook Hotel, where he, along with his wife Wendy and their son Danny, must live isolated from the rest of the world for the winter. But they aren't prepared for the madness that lurks within.",
"release_date": "1980-05-22",
"inventory": 3
}
}]
}
89 changes: 61 additions & 28 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,91 @@
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var express = require('express')
var path = require('path')
var favicon = require('serve-favicon')
var logger = require('morgan')
var cookieParser = require('cookie-parser')
var bodyParser = require('body-parser')
var routes = require('./routes/index')
var app = express()

var routes = require('./routes/index');
var massive = require("massive")

var app = express();
var app = module.exports = express()
var connectionString = "postgres://localhost/video_store"

// connect to Massive and get the db instance. You can safely use the
// convenience sync method here because its on app load
// you can also use loadSync - it's an alias
var massiveInstance = massive.connectSync({connectionString : connectionString})

// Set a reference to the massive instance on Express' app:
app.set('db', massiveInstance)

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'jade')

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')))
app.use(logger('dev'))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cookieParser())
app.use(express.static(path.join(__dirname, 'public')))

var indexRoutes = require('./routes/index')
// /zomg inside index route
app.use('/', indexRoutes)
app.use('/zomg', indexRoutes)
// customers
// GET
var customerRoutes = require('./routes/customers')
app.use('/customers', customerRoutes)
// POST - check-in and check-out
// needs id

// rentals
// GET
var rentalsRoutes = require('./routes/rentals')
app.use('/rentals', rentalsRoutes)
// title
// needs customer id, movie title

app.use('/', routes);
// movies
// GET
var moviesRoutes = require('./routes/movies')
app.use('/movies', moviesRoutes)
// needs title

// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
var err = new Error('Not Found')
err.status = 404
next(err)
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great error handling!


// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.status(err.status || 500)
res.render('error', {
message: err.message,
error: err
});
});
})
})
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.status(err.status || 500)
res.render('error', {
message: err.message,
error: {}
});
});
})
})


module.exports = app;
module.exports = app
70 changes: 70 additions & 0 deletions controllers/customers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
var Customer = require('../models/customer')
var Rental = require('../models/rental')

CustomersController = {
locals: {
title: 'CUSTOMERS CUSTOMERS CUSTOMERS'
},

getCustomers: function(req, res) {
Customer.all (function (error, customers) {
if (error) {
var err = new Error("Error retrieving customer list:\n" + error.message);
err.status = 500;
next(err);
} else {
res.json(customers)
}
})
},

getCustomersShow: function (req, res, next) {
Customer.find(req.params.name, function(error, customer) {
if(error) {
var err = new Error("No such customer");
err.status = 404;
next(err);
} else {
res.json(customer)
}
})
},

getCustomersSort: function (req, res, next) {
Customer.sort(req.params.field, req.query.n, req.query.p, function(error, customer) {
if (error) {
var err = new Error("Error retrieving customer list:\n" + error.message);
err.status = 500;
next(err);
} else {
res.json(customer)
}
})
},

getRentalsCurrent: function (req, res, next) {
Rental.findCurrent(req.params.id, function (error, movie) {
if (error) {
var err = new Error("Error retrieving current rentals:\n" + error.message);
err.status = 500;
next(err);
} else {
res.json(movie)
}
})
},

getRentalsHistory: function (req, res, next) {
Rental.findHistory(req.params.id, function (error, movie) {
if (error) {
var err = new Error("Error retrieving rental history:\n" + error.message);
err.status = 500;
next(err);
} else {
res.json(movie)
}
})
}
}

module.exports = CustomersController
15 changes: 15 additions & 0 deletions controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
IndexController = {
locals: {
title: 'INDEX INDEX INDEX'
},

getIndex: function(req, res) {
res.status(200).json({whatevs: 'whatevs!!!'})
},

getZomg: function(req, res) {
res.status(200).json({it_works: 'Yeah MF!!!'})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea MF!!

}
}

module.exports = IndexController
Loading