diff --git a/app/scripts/app.js b/app/scripts/app.js index 1c860ba..c21b1e6 100644 --- a/app/scripts/app.js +++ b/app/scripts/app.js @@ -20,6 +20,10 @@ angular.module('fitrecordMeanApp', [ templateUrl: 'partials/signup', controller: 'SignupCtrl' }) + .when('/lifts', { + templateUrl: 'partials/lifts', + controller: 'LiftCtrl' + }) .when('/settings', { templateUrl: 'partials/settings', controller: 'SettingsCtrl', @@ -28,9 +32,9 @@ angular.module('fitrecordMeanApp', [ .otherwise({ redirectTo: '/' }); - + $locationProvider.html5Mode(true); - + // Intercept 401s and redirect you to login $httpProvider.interceptors.push(['$q', '$location', function($q, $location) { return { @@ -50,7 +54,7 @@ angular.module('fitrecordMeanApp', [ // Redirect to login if route requires auth and you're not logged in $rootScope.$on('$routeChangeStart', function (event, next) { - + if (next.authenticate && !Auth.isLoggedIn()) { $location.path('/login'); } diff --git a/lib/controllers/lifts.js b/lib/controllers/lifts.js new file mode 100644 index 0000000..491a292 --- /dev/null +++ b/lib/controllers/lifts.js @@ -0,0 +1,14 @@ +'use strict'; + +var mongoose = require('mongoose'), + Lift = mongoose.model('Lift'); + +exports.index = function(req, res) { + return Lift.find(function (err, things) { + if (!err) { + return res.json(things); + } else { + return res.send(err); + } + }); +}; \ No newline at end of file diff --git a/lib/routes.js b/lib/routes.js index a635400..47b7e2a 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -3,6 +3,7 @@ var api = require('./controllers/api'), index = require('./controllers'), users = require('./controllers/users'), + lifts = require('./controllers/lifts'), session = require('./controllers/session'); var middleware = require('./middleware'); @@ -20,7 +21,7 @@ module.exports = function(app) { app.get('/api/users/me', users.me); app.get('/api/users/:id', users.show); - app.get('/api/lifts', api.awesomeThings); + app.get('/api/lifts', lifts.index); app.post('/api/session', session.login); app.del('/api/session', session.logout);