Permalink
Browse files

lifts api grabs data from mongo

  • Loading branch information...
1 parent 59b1403 commit 6af4c061350be09f48189646584c9998d032f326 @mikepmunroe committed Feb 24, 2014
Showing with 23 additions and 4 deletions.
  1. +7 −3 app/scripts/app.js
  2. +14 −0 lib/controllers/lifts.js
  3. +2 −1 lib/routes.js
View
@@ -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');
}
@@ -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);
+ }
+ });
+};
View
@@ -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);

0 comments on commit 6af4c06

Please sign in to comment.