├── .gitignore ├── img ├── app.png └── issue_01.png ├── 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 └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | *.log 4 | -------------------------------------------------------------------------------- /img/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webmakaka/Build-a-Real-Time-web-app-in-node.js-Angular.js-mongoDB/HEAD/img/app.png -------------------------------------------------------------------------------- /img/issue_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webmakaka/Build-a-Real-Time-web-app-in-node.js-Angular.js-mongoDB/HEAD/img/issue_01.png -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "database": "mongodb://root:root@ds031661.mlab.com:31661/userstory", 3 | "port": process.env.PORT || 3000, 4 | "secretKey": "YourSecretKey" 5 | }; 6 | -------------------------------------------------------------------------------- /public/app/directives/reverse.js: -------------------------------------------------------------------------------- 1 | angular.module('reverseDirective', []) 2 | .filter('reverse', function(){ 3 | return function(items){ 4 | return items.slice().reverse(); 5 | }; 6 | }); 7 | -------------------------------------------------------------------------------- /public/app/app.js: -------------------------------------------------------------------------------- 1 | angular 2 | .module('MyApp', ['appRoutes', 'mainCtrl', 'authService', 'userCtrl', 'userService', 'storyService', 'storyCtrl', 'reverseDirective']) 3 | .config(function($httpProvider){ 4 | $httpProvider.interceptors.push('AuthInterceptor'); 5 | }); 6 | -------------------------------------------------------------------------------- /app/models/story.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose'); 2 | 3 | var Schema = mongoose.Schema; 4 | 5 | var StorySchema = new Schema({ 6 | 7 | creator: {type: Schema.Types.ObjectId, fef: 'User'}, 8 | content: String, 9 | creted: {type: Date, default: Date.now} 10 | 11 | }); 12 | 13 | module.exports = mongoose.model('Story', StorySchema); 14 | -------------------------------------------------------------------------------- /public/app/services/userService.js: -------------------------------------------------------------------------------- 1 | angular.module('userService', []) 2 | .factory('User', function($http){ 3 | var userFactory = {}; 4 | userFactory.create = function(userData){ 5 | return $http.post('/api/signup', userData); 6 | }; 7 | 8 | userFactory.all = function(){ 9 | return $http.get('/api/users'); 10 | }; 11 | 12 | return userFactory; 13 | }); 14 | -------------------------------------------------------------------------------- /public/app/views/pages/allStories.html: -------------------------------------------------------------------------------- 1 |
{{ each.content }}
15 |Login to write your story
7 | Login 8 |{{ each.content }}
35 |