Skip to content

Commit

Permalink
lifts api grabs data from mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepmunroe committed Feb 24, 2014
1 parent 59b1403 commit 6af4c06
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/scripts/app.js
Expand Up @@ -20,6 +20,10 @@ angular.module('fitrecordMeanApp', [
templateUrl: 'partials/signup', templateUrl: 'partials/signup',
controller: 'SignupCtrl' controller: 'SignupCtrl'
}) })
.when('/lifts', {
templateUrl: 'partials/lifts',
controller: 'LiftCtrl'
})
.when('/settings', { .when('/settings', {
templateUrl: 'partials/settings', templateUrl: 'partials/settings',
controller: 'SettingsCtrl', controller: 'SettingsCtrl',
Expand All @@ -28,9 +32,9 @@ angular.module('fitrecordMeanApp', [
.otherwise({ .otherwise({
redirectTo: '/' redirectTo: '/'
}); });

$locationProvider.html5Mode(true); $locationProvider.html5Mode(true);

// Intercept 401s and redirect you to login // Intercept 401s and redirect you to login
$httpProvider.interceptors.push(['$q', '$location', function($q, $location) { $httpProvider.interceptors.push(['$q', '$location', function($q, $location) {
return { return {
Expand All @@ -50,7 +54,7 @@ angular.module('fitrecordMeanApp', [


// Redirect to login if route requires auth and you're not logged in // Redirect to login if route requires auth and you're not logged in
$rootScope.$on('$routeChangeStart', function (event, next) { $rootScope.$on('$routeChangeStart', function (event, next) {

if (next.authenticate && !Auth.isLoggedIn()) { if (next.authenticate && !Auth.isLoggedIn()) {
$location.path('/login'); $location.path('/login');
} }
Expand Down
14 changes: 14 additions & 0 deletions 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);
}
});
};
3 changes: 2 additions & 1 deletion lib/routes.js
Expand Up @@ -3,6 +3,7 @@
var api = require('./controllers/api'), var api = require('./controllers/api'),
index = require('./controllers'), index = require('./controllers'),
users = require('./controllers/users'), users = require('./controllers/users'),
lifts = require('./controllers/lifts'),
session = require('./controllers/session'); session = require('./controllers/session');


var middleware = require('./middleware'); var middleware = require('./middleware');
Expand All @@ -20,7 +21,7 @@ module.exports = function(app) {
app.get('/api/users/me', users.me); app.get('/api/users/me', users.me);
app.get('/api/users/:id', users.show); 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.post('/api/session', session.login);
app.del('/api/session', session.logout); app.del('/api/session', session.logout);
Expand Down

0 comments on commit 6af4c06

Please sign in to comment.