├── config.js ├── public └── app │ ├── directives │ └── reverse.js │ ├── app.js │ ├── services │ ├── userService.js │ ├── storyService.js │ └── authService.js │ ├── views │ ├── pages │ │ ├── allStories.html │ │ ├── login.html │ │ ├── signup.html │ │ └── home.html │ └── index.html │ ├── controllers │ ├── userCtrl.js │ ├── storyCtrl.js │ └── mainCtrl.js │ └── app.routes.js ├── app ├── models │ ├── story.js │ └── user.js └── routes │ └── api.js ├── package.json └── server.js /config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | "database": "mongodb://root:abc123@ds045031.mongolab.com:45031/userstory", 4 | "port": process.env.PORT || 3000, 5 | "secretKey": "YourSecretKey" 6 | 7 | } -------------------------------------------------------------------------------- /public/app/directives/reverse.js: -------------------------------------------------------------------------------- 1 | angular.module('reverseDirective', []) 2 | 3 | .filter('reverse', function() { 4 | 5 | return function(items) { 6 | return items.slice().reverse(); 7 | } 8 | 9 | }); -------------------------------------------------------------------------------- /public/app/app.js: -------------------------------------------------------------------------------- 1 | angular.module('MyApp', ['appRoutes', 'mainCtrl', 'authService', 'userCtrl', 'userService', 'storyService', 'storyCtrl', 'reverseDirective']) 2 | 3 | .config(function($httpProvider) { 4 | 5 | $httpProvider.interceptors.push('AuthInterceptor'); 6 | 7 | 8 | }) -------------------------------------------------------------------------------- /app/models/story.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose'); 2 | 3 | var Schema = mongoose.Schema; 4 | 5 | 6 | var StorySchema = new Schema({ 7 | 8 | creator: { type: Schema.Types.ObjectId, ref: 'User' }, 9 | content: String, 10 | created: { type: Date, defauly: Date.now} 11 | 12 | }); 13 | 14 | module.exports = mongoose.model('Story', StorySchema); -------------------------------------------------------------------------------- /public/app/services/userService.js: -------------------------------------------------------------------------------- 1 | angular.module('userService', []) 2 | 3 | 4 | .factory('User', function($http) { 5 | 6 | var userFactory = {}; 7 | 8 | userFactory.create = function(userData) { 9 | return $http.post('/api/signup', userData); 10 | } 11 | 12 | userFactory.all = function() { 13 | return $http.get('/api/users'); 14 | } 15 | 16 | 17 | 18 | return userFactory; 19 | 20 | }); -------------------------------------------------------------------------------- /public/app/views/pages/allStories.html: -------------------------------------------------------------------------------- 1 | 2 |
{{ each.content }}
17 |Login to write your story
10 | Login 11 |{{ each.content }}
40 |